My service is restarted each time the application

2019-08-26 13:26发布

问题:

I have a service in my app and start it as follows

Intent intent = new Intent(this, Prueba.class);
startService(intent);

Also, your method return onStartCommand STAR_STICKY;

However, every time I close the app the service is restarted. As for the service do not restarts and keep running?

回答1:

Please check it out may be this can be useful for you:

http://developer.android.com/reference/android/app/Service.html#ServiceLifecycle