@
standin000 绿色守护的作者在 bugreport 列出了一些常见的保活措施:
https://issuetracker.google.com/issues/62480012"
1. Restart the service with a frequent periodic alarm (less than 5 minutes), causing the service being stopped and started again and again. (same applied to JobScheduler and SyncAdapter)
2. Restart the service inside its Service.onDestroy(), reviving the service immediately upon stopping.
3. Raise the background service to foreground service, when the screen is off to dodge from observation by user.
4. Bind to each other within 2 services, to fool the activity manager to consider them as bound services.
5. Restart service from JNI native library with "am start-service".
"
我觉得比较可能是通过另一个应用的 SDK 发出 expilcit Intent 启动,或者 Sync/Job 的方式,它们都能绕过 Force Close
有 Android 7 的话,RUN_IN_BACKGROUND 应该能对付这里的所有情况
然而如这个 bug report 所说,7~7.1 的这个实现有 bug(直到 Android 8 DP4 修复),只会杀进程的第一个 service