Sunday, April 20, 2014

service from startup problems


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?
<-! 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:
cited a floor wch18956441322 reply:
onStartCommand return START_STICKY?
should be returned START_NOT_STICKY non-sticky will not automatically restart
Reply:
reference to the third floor CuGBabyBeaR reply:
Quote: references to a floor wch18956441322 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!
Reply:
references, 4th Floor wch18956441322 reply:
Quote: references to the third floor CuGBabyBeaR reply:

Quote: references to a floor wch18956441322 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;
...
}

(・ ิ ω ・ ิ) want to help you

No comments:

Post a Comment