设置某些应用的优先级不让被杀

本文介绍如何通过修改配置文件PromotionAppAdjList.ini并解析其内容,将某些应用添加到ArrayList中,然后在ActivityManagerService.java的computeOomAdjLocked函数中,检查并调整这些应用的内存优先级,防止它们被系统杀死。这种方法特别适用于保持运行中的 instrumentation 应用处于前台状态。
摘要由CSDN通过智能技术生成

 

1:设置配置文件 PromotionAppAdjList.ini

2:读取配置文件放数组

private ArrayList<String> mPromotionAppAdjList = new ArrayList<String>();
    private String PROMOTION_APP_ADJ_LIST = "/nwdappconfig/app/PromotionAppAdjList.ini";
    private void parsePromotionAppAdjList() {
        InputStream is = null;
        try {
            is = new FileInputStream(PROMOTION_APP_ADJ_LIST);
        } catch (FileNotFoundException e) {
            Log.w(TAG, "Couldn't find " + PROMOTION_APP_ADJ_LIST);
            return;
        }

        try {
            BufferedReader br = new BufferedReader(
                new InputStreamReader(is), 256);
            String line;
            while ((line = br.readLine()) != null) {
                line = line.trim();
                if (

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值