java - 当应用程序从堆栈中终止时,后台服务停止
问题描述
当应用程序从堆栈中被杀死时,后台服务停止
public int onStartCommand(Intent intent, int flags, int startId) {
googleApiClient = new GoogleApiClient.Builder(getApplicationContext())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
return START_STICKY;
}
解决方案
没有直接的解决方案,但下面的链接中提到了解决方法,
https://stackoverflow.com/a/58162451/7579041
上面的链接适用于库存 ROM 和自定义 ROM 设备,如 OnePlus、OPPO、VIVO 等
我希望这会帮助你
推荐阅读
- python - ValueError:运行 django 测试时无法解析相关模型“auth.Group”
- grails - 不在一个 GSP 上但在另一个 Grails 上呈现的域内容列表
- python-3.x - 如何找到用python捕获符号值的两条线段之间的最短距离
- angular - 每次在 netlify 上构建后,Angular 应用程序都需要手动刷新
- c++ - 通过索引元素访问字符串并尝试打印它
- c++ - 定义 set 方法的 const& 和 && 版本时的最佳实践是什么?
- c - 使用结构最有效的方法是什么?
- python - 在 python 中将 3D CAD 文件导入为 dask 数组
- ionic-framework - 在 ios 中重新打开应用程序时,离子 4 电容器存储变得清晰
- sql-server - 如何在sql server中查找存储过程中调用的所有函数和存储过程