geekslot geekslot - 1 year ago 79
Android Question

Android - Service stops when swiping app from recent apps

I've developed an android application with a service that runs in the background
the service is called like that

startService(new Intent(getApplicationContext(),myService.class));

but when I remove the app from the recent apps, the service stops and it crashes if I test it..
is there a way to prevent the service from being destroyed when swiping the app from the recent apps?

thank you

Answer Source

You can register a service to run on a repeating cycle using AlarmManager

The service will run even if the application is not running.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download