android提高进程优先级的方法
2015-03-17 11:30
155 查看
方法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"』
具体修改示例如下:
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()方法中进行降低优先级操作
onStart() 方法中进行提高优先级操作,然后在onStop()方法中进行降低优先级操作
这个方法可以将对应AP的ADJ临时提高到2。
方法2:
找到这个进程对应的AndroidMannifest.xml文件,在其中添加属性『android:persistent="true"』,这样可以将该进程设置为常驻内存进程,就可以降低被Kill的概率。以Acore进程为例,在 /package/providers/ContactsProvider/AndroidMannifest.xml
文件中增加一行『android:persistent="true"』
具体修改示例如下:
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()方法中进行降低优先级操作
相关文章推荐
- Android基础总结——进程优先级及提高优先级的方法(Service尽量不死之法)
- Android基础总结——进程优先级及提高优先级的方法(Service尽量不死之法)
- Android基础总结——进程优先级及提高优先级的方法(Service尽量不死之法)
- Android中提高进程优先级的方法策略
- Android进阶之进程优先级及提高优先级的方法(进程保活)
- android提高进程优先级的方法
- Android 进程优先级及提高优先级的方法(Service尽量不死之法)
- android提高进程优先级的若干方法
- Android中提高后台服务进程优先级的方法
- Android基础总结——进程优先级及提高优先级的方法
- android 提高进程的优先级
- android 提高进程的优先级
- 一种提高Android应用进程存活率新方法
- 一种提高Android应用进程存活率新方法
- Android提高Service优先级的方法分析
- android如何让service不被杀死-提高进程优先级
- 提高Android Service 优先级的方法 .
- [android基础知识] 之十八: android service提高自身优先级以及防止被杀的方法汇总
- 一种提高Android应用进程存活率新方法
- 提高service的进程优先级的方法之一,startForeground