1. re-write the following method in service. This method has three return values. start_sticky indicates that the service is automatically overwritten after it is killed.
@ Override
Public int onstartcommand (intent, int flags, int startid ){
Return start_sticky;
}----------------
@ Override
Public int onstartcommand (intent, int flags, int startid ){
// Todo auto-generated method stub
Log. V ("trafficservice", "startcommand ");
Flags = start_sticky;
Return super. onstartcommand (intent, flags, startid );
// Return start_redeliver_intent;
}
2. Restart the service in ondestroy () of the service.
Public void ondestroy (){
Intent localintent = new intent ();
Localintent. setclass (this, myservice. Class); // restart the service upon destruction
This. startservice (localintent );
}---------------------------------------------
When a process is killed by a QQ Butler, the system's built-in mandatory kill function (in settings) is called. During the kill process, the entire process of the application is stopped, of course, if the service is forced to kill in running, the process is still displayed. Neither kill the entire process nor kill the service that falls into the application, nor restart the service. I don't know how you restarted it...
PS: In eclipse, when the stop button is used to kill the process, the service will be restarted.
Kill:
1. Stop Service in settings
In the ondestroy method, call startservice to restart the service.
2. Force Stop Application in settings
Capture System broadcast (action is Android. Intent. Action. package_restarted)
3. Kill the running task with a third-party Application
Improve Service priority