android 服务不被kill方法收集
16lz
2021-01-26
方法来自网上,只作收集整理,以方便自己查询
1、提升服务的优先级 <intent-filter android:priority="1000">
2 、application标签中添加android:persistent属性
3、在service中重写onStartCommand方法, START_STICKY是service被kill掉后自动重写创建
return super.onStartCommand(intent, START_STICKY, startId);
4、 public void onDestroy() {
Intent ReIntent = new Intent();
ReIntent.setClass(this, MyService.class); //销毁时重新启动Service
this.startService(ReIntent);
}
更多相关文章
- WebView的使用,android与JS混编
- Building Custom Components/建立自定义组件
- Android获取应用运行次数
- Android中打开网络设置界面
- Android学习笔记(三):Andriod程序框架
- 使用IntelliJ IDEA(androidstudio前身)开发android移动应用前的基
- Android(安卓)-- 自定义View
- 关于android设备唯一区分device id的取得
- 【记录】Android(安卓)广播的发送与接收