开发者

How-to kill my app without killing the service it sarted (debugging)

My android application starts a service when runned for the first time. That service handles network connect开发者_JS百科ion.

If the device is out of free space, my application can be killed, but the service will remain alive (except on certain extreme case, I know.). When the app will be restarted, it will need to restore it state according to the service state (no problem for that).

Here's my question: How can I kill my application, but not the associated service ? That's only for debugging purpose, I would like to test if the state is correctly restored.

When I try to kill the app with adb, ddms or advanced task killer, the service is killed too.

Any ideas ?

Thanks,

Code: I start my service like that:

final Intent intent = new Intent(this, Service.class);
mStartServiceResult = startService(intent);
mIsBound = bindService(intent, mConnection, 0);

and use startForeground / setForeground to prevent my service to be killed.


If the device is out of free space, my application can be killed, but the service will remain alive (except on certain extreme case, I know.).

No. Some or all of your activities might be destroyed, which would leave the service running. Or your process may be terminated, in which case your service will also shut down.

How can I kill my application, but not the associated service ?

That is not possible, sorry.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜