2

I have an application in which i am taking device administrator and that application continuously connect to server to send phone data.

But this background service is stopped after some days and also stopped when anybody kill with task manager !

Even FCM receiver is stopped with task manager !

So is there any way that i can service for my app like whatsapp , fb and other social app . These app never killed with task manager and if it was killed then it will restart automatically.

How can i achieve this ?

  • i sthink it's right solution, https://stackoverflow.com/questions/2681499/android-how-to-auto-restart-application-after-its-been-force-closed – Lex Hobbit Aug 03 '17 at 13:42

1 Answers1

0

You can make your service as never ending process even task manager kills the service but it will start automatically by help of

START_STICKY
START_REDELIVER_INTENT

STICKY: ...Android will restart your service, because that particular flag is set. REDELIVER_INTENT: ...Android will restart the service AND redeliver the same intent to onStartCommand() of the service, because, again, of the flag.

     public int onStartCommand(Intent intent, int flags, int startId) {
       //to do
        return START_REDELIVER_INTENT;
     }
samsad
  • 1,336
  • 1
  • 10
  • 15
  • I have tried this on xiomi device but this wont work if they kill app from task manager ! –  Aug 03 '17 at 06:57