android提高进程优先级的若干方法
来源:互联网 发布:淘宝的拍照权限设置 编辑:程序博客网 时间:2024/06/06 03:20
转载自:http://www.2cto.com/kf/201402/279086.html,在此表示感谢
方法1: 提高进程优先级 startForeground(1, new Notification()); 降低进程优先级 stopForeground(true);
onStart() 方法中进行提高优先级操作,然后在onStop()方法中进行降低优先级操作这个方法可以将对应AP的ADJ临时提高到2。
方法2:
找到这个进程对应的AndroidMannifest.xml文件,在其中添加属性『android:persistent="true"』, 这样可以将该进程设置为常驻内存进程,就可以降低被Kill的概率。以Acore进程为例, 在 /package/providers/ContactsProvider/AndroidMannifest.xml 文件中增加一行『android:persistent="true"』
具体修改示例如下:
<application android:process="android.process.acore"
android:label="@string/app_label"
android:icon="@drawable/app_icon"
android:allowBackup="false"
android:persistent="true"
> 方法3:
在需要提高优先级的地方调用:
final Intent it = new Intent();
it.setAction("android.intent.action.BOOST_DOWNLOADING");
it.putExtra("package_name", "com.android.contacts");
it.putExtra("enabled", true);
context.sendBroadcast(it);
在需要恢复到正常优先级时调用:
final Intent it = new Intent();
it.setAction("android.intent.action.BOOST_DOWNLOADING");
it.putExtra("package_name", "com.android.contacts");
it.putExtra("enabled", false);
context.sendBroadcast(it);
onStart() 方法中进行提高优先级操作,然后在onStop()方法中进行降低优先级操作
这个方法可以将对应AP的ADJ临时提高到7。
0 0
- android提高进程优先级的若干方法
- android提高进程优先级的方法
- android提高进程优先级的方法
- android 提高进程的优先级
- android 提高进程的优先级
- Android中提高后台服务进程优先级的方法
- Android中提高进程优先级的方法策略
- Android进阶之进程优先级及提高优先级的方法(Service进程防杀死)
- Android进程提高优先级
- Android基础总结——进程优先级及提高优先级的方法
- Android 进程优先级及提高优先级的方法(Service尽量不死之法)
- 提高进程的优先级
- 提高Android Service 优先级的方法
- 提高Android Service 优先级的方法 .
- Android基础总结——进程优先级及提高优先级的方法(Service尽量不死之法)
- Android基础总结——进程优先级及提高优先级的方法(Service尽量不死之法)
- Android基础总结——进程优先级及提高优先级的方法(Service尽量不死之法)
- Android基础总结——进程优先级及提高优先级的方法(Service尽量不死之法)
- IT资讯--------抓取各个博客上的文章
- 38. Count and Say【E】【79】【leetcode】
- 微信商户发放红包接口调试经验总结
- C# 中线程资源访问互斥量
- android自定义一个带进度条的button
- android提高进程优先级的若干方法
- 单元测试一NUnit
- 克服VR眩晕之帧数:提升UE4内容实时渲染效率
- Android创建组合控件
- hadoop伪分布式ha框架搭建
- 开发人员系统功能设计常用办公软件分享
- 剑指offer-面试题4:替换空格
- [疯狂Java笔记]AWT容器简介
- 蓝桥杯 打印图形(分型法)