简体   繁体   中英

How to start a Service even if we force the application in Android.?

我创建了一个Activity并在该Activity中启动了服务。即使我们强制关闭应用程序,该服务也应在后台运行。请帮助我解决此问题。

Services run on the same proccess of its application. For this, they should die if its application is force closed.

Maybe you should think about using different threads: Processes and Threads

When app gets force close then service gets destroyed. Check out below link, which shows a Return value from onstartCommand func. http://developer.android.com/reference/android/app/Service.html#START_STICKY By this system restarts service. Check this also. http://developer.android.com/reference/android/app/Service.html#START_CONTINUATION_MASK http://developer.android.com/reference/android/app/Service.html#START_REDELIVER_INTENT

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM