作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
所以,我在 Stackoverflow 中看到了这个问题的答案,但我没有找到最终答案。所以,我遇到了一个问题:我已经将线程分离到套接字。我在 Application onCreate 方法上创建并启动这个线程。当应用程序从最近的应用程序列表中被杀死时,我需要拦截这个线程。如果用户按下后退按钮,系统将调用 onDestroy,这种情况我可以拦截套接字线程。但是,当用户从最近的应用程序列表中杀死应用程序时,我无法拦截套接字线程。
有人有最终答案如何解决这个问题吗?
最佳答案
您可以在 Manifest 文件中使用 stopWithTask 标志作为服务的 true 来执行此操作。
例子:
<service
android:enabled="true"
android:name=".MyService"
android:exported="false"
android:stopWithTask="true" />
关于安卓 : How to detect app killed from recent apps list?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26771795/
我是一名优秀的程序员,十分优秀!