android - How to avoid restarting the service? -
I have created a service and want that this service is always running. But when I turn off the service, Android removes the service, and then it restarts.
My application is created by pressing the button in the menu. Activity as follows:
startService (new intent (getApplicationContext (), MyService.class)); Logcat:
01-22 11: 44: 52.242 1218-138 9 / System_process I / Activityman: Killing 2040: com.my.application / U0a10046: Delete the work 01-22 11: 44: 52.252 1218-1218 / System_prosse W / Activity Manager: Com.my.application / .MyService 5000ms 01-22 11: 44 to restart the Comrade working crashed : 57.272 2061-2061 /? D / DelWiki: Late not enabled CzechJNI (Pre-activated) 01-22 11: 44: 57.272 1218-1235 / System_process I / Activityman: For service com. Com.my.application com.my.application / .MyService: pid = 2061 uid = 10046 gids = {50046, 1028}
In your service category, add" Return as "START_NOT_STICKY" return:
public int onStartCommand (intended intent, int-flags, int startId) {// your code ... return START_NOT_STICKY; } START_NOT_STICKY means that (service.java is mentioned on the Java doc):
Onstart Commands (intent, intestine, int ): If this process of service has been killed (after returning from the intestine, int), and there is no new initial intention to give it, then to exit the state that started the service and Don is clear of the future Until the service is started, do not rebuild the service (with an intention to tap) Shirt Command (Intent, Int, Int) will not call, because it will not be the relay, if pending intent to any man.
Comments
Post a Comment