有一种方法可以设置app永远不会被kill,AndroidManifest.xml 中添加: android:persistent="true" 适用于放在/system/app下的app 设置后app提升为系统核心级别,任何情况下不会被kill掉, settings->applications里面也会屏蔽掉stop操作, 设置前 Proc#19:adj=svc/B4067b028255:com.xxx.xxx/10001(started-services) #cat/proc/255/oom_adj 4 设置后 PERS#19:adj=core/F406291f0155:com.xxx.xxx/10001(fixed) #cat/proc/155/oom_adj -12

lowmemorykiller的操作规则比如为

write /sys/module/lowmemorykiller/parameters/adj 0,1,2,4,7,15

write /sys/module/lowmemorykiller/parameters/minfree 2048,3072,4096,6144,7168,8192

可以看到,设置persistent后, oom_adj=-12,永远没有机会被lowmemorykiller处理

android:persistent
Whether or not the application should remain running at all times — "true" if it should, and "false" if not. The default value is "false". Applications should not normally set this flag; persistence mode is intended only for certain system applications

代码


可以看到同时符合FLAG_SYSTEM(/system/app目录)及FLAG_PERSISTENT(android:persistent="true")

的app,设置app.maxAdj = CORE_SERVER_ADJ(-12),而adj=-12不会被lowmemorykiller处理

更多相关文章

  1. android EditText设置不可写
  2. android“设置”里的版本号
  3. 在Fragment中设置控件点击方法,执行失败。
  4. Android(安卓)闹钟管理类的使用
  5. Android的Handler机制详解3_Looper.looper()不会卡死主线程
  6. Android设置通知栏/状态栏透明改变通知栏颜色和app最上部分颜色
  7. android 设置中划线 下划线等
  8. Andorid Dialog 示例【慢慢更新】
  9. android图表ichartjs

随机推荐

  1. 从Java开发到Android再到微信小程序
  2. Android(安卓)模仿QQ登录下拉历史列表
  3. Android优化——绘制优化之android系统显
  4. android仿iPhone滚轮控件实现及源码分析(
  5. Android实现二维码扫描功能(五)-封装与接入
  6. Android仿游戏答题
  7. Android基础-Content Provider
  8. Android炒菜现炒现卖之-------- AOP 入门
  9. Android(安卓)JNI和NDK学习(02)--静态方
  10. Android横竖屏解析