1

Till Android 6.0 whenever I Kill my app my service gets restarted automatically, but when I tested it in 7.1.1 my service does not gets restart it stops.

I tried restarting the service in activity onDestroy like this,

@Override
    protected void onDestroy() {
        super.onDestroy();
        Util.printMessage("onDestroy.....");
        Intent locationIntent = new Intent(getApplicationContext(), SupportService.class);
        startService(locationIntent);
        Util.printMessage("running...?..." + isMyServiceRunning(SupportService.class));

    }

But this solution did not work, can anyone suggest what is the issue or how to start the service again and same for the boot change receiver my broadcast does not get call when device is rebooted.

Siddhesh Pawar
  • 259
  • 4
  • 24

1 Answers1

1

Change the return type of onStartCommand() with START_STICKY. if the service destroy by system it will start automatically... for more info about START_STICKY Click

code4rox
  • 941
  • 9
  • 34