Home » Android » Running service after application close

Running service after application close

Posted by: admin November 1, 2017 Leave a comment


My application need to run service in background even if user closed the app.
But, when I closed my app, the service stop and restart. So, all variables who are in the service are reset.

After search on google, I have found that :

public int onStartCommand(Intent intent, int flags, int startId) {
    return START_STICKY;

But it do not work. My service is reset.


Hello you need to consider the fact that If your app targets API level 26 or higher, the system imposes restrictions on running background services when the app itself is not in the foreground. In most cases like this, your app should use a scheduled job instead. You can read more on this link:


Did you add your service to the AndroidManifest.xml?