I wrote a service, which communicate via socket calls stopSelf and system.exit (0), service was terminated. But after a child, I found this service himself started. Will you greatly is what causes it, and how to solve?
<-! Baidu Button BEGIN -> more Share to: <-! Baidu Button END ->
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) -> Reply: onStartCommand return START_STICKY? Reply: View service start conditions, it is estimated what the intent of your program and then start receiving the service Reply: should be returned START_NOT_STICKY non-sticky will not automatically restart Reply:
For a long time not to use your own manually stop and then restart, and where they should be restarted! Reply:
onStartCommand return START_STICKY?
should be returned START_NOT_STICKY non-sticky will not automatically restart
For a long time not to use your own manually stop and then restart, and where they should be restarted!
Uh, I wrote in onCreate Lane. . . Reply:
public int onStartCommand (Intent intent, int flags, int startId) { / / TODO Auto-generated method stub handler = new Handler () {/ / new Handler object @ Override public void handleMessage (Message msg) {/ / accept the msg / / TODO Auto-generated method stub if (msg.what == 12345) { tag = line; System.out.println ("handle:" + tag); if (tag.equals ("close")) { System.out.println ("Service is stopped."); stopSelf (); / / Close Service System.exit (0); } } } }; return START_NOT_STICKY; }
I would like to ask me write this, and return back there with you. . . Reply:
The reply was deleted administrator at 2013-09-16 14:28:07
Reply: Here Cadogan a try
if (tag.equals ("close")) {... stopService (intent) ;/ / close the Service; import android.content.Context; ... }
No comments:
Post a Comment