Android防止进程被杀
2016-06-06 18:18
447 查看
有时开启新的app而内存不够时,其它app可能会被Out
Of Memory Killer清除防止进程不被杀死的办法:
1.在AndroidManifest.xml文件中设置persistent属性为true
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:persistent="true">
2.在前端运行程序
private void startForeground() {
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle(getResources().getString(R.string.app_name))
.setTicker(getResources().getString(R.string.app_name))
.setContentText("Running")
.setSmallIcon(R.drawable.unlock)
.setContentIntent(null)
.setOngoing(true)
.build();
startForeground(9999,notification);
}
Of Memory Killer清除防止进程不被杀死的办法:
1.在AndroidManifest.xml文件中设置persistent属性为true
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:persistent="true">
2.在前端运行程序
private void startForeground() {
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle(getResources().getString(R.string.app_name))
.setTicker(getResources().getString(R.string.app_name))
.setContentText("Running")
.setSmallIcon(R.drawable.unlock)
.setContentIntent(null)
.setOngoing(true)
.build();
startForeground(9999,notification);
}
相关文章推荐
- Android Studio编译、导入aar库的方法
- java(Android)线程池
- Android后台监控其他应用是否全屏
- Android之右上角三点menu消失原因
- Android Studio使用Lint进行代码检查
- 安卓判断是否有Root权限
- 【翻译】通讯录数据的存取(一)——获取通讯录列表
- Google Android开发者文档系列-创建有内容分享特性的应用之获取文件信息
- Android 系统BUG
- Android studio 代码混淆
- Android 开发者,你真的会用textview(maxEms和maxLength)的属性吗?
- android Rect四个参数介绍
- Android 串口通信
- RxJava+RxAndroid+MVP入坑实践(一:基础篇)
- 个人使用的Android Studio快捷键(MAC版)
- 如何设置Android Studio左边项目栏的字体大小?
- android ExifInterface类
- Android基础之图片自动滚动
- android fragment知识点小结
- mac下android环境搭建笔记(android studio)