微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – 不再需要ActivityManager – 不是服务问题

我正在开发一个开源应用程序(droidwall fork),我遇到的问题之一是当系统重新启动时iptables规则未正确应用.它适用于大多数 Android版本.但是在某些特定的ROMS(CM 10.1)上,它提供了以下logcat
12-26 08:39:27.116 I/ActivityManager(582): 
No longer want dev.ukanth.ufirewall (pid 2297): empty #17

我的代码工作如下,

private Handler mHandler = new Handler(Looper.getMainLooper());
@Override
public void onReceive(final Context context,final Intent intent) {
    if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
        if (Api.isEnabled(context.getApplicationContext())) {
            final Handler toaster = new Handler() {
                public void handleMessage(Message msg) {
                    if (msg.arg1 != 0) Toast.makeText(context,msg.arg1,Toast.LENGTH_SHORT).show();
                }
            };

            mHandler.post(  
            // Start a new thread to enable the firewall - this prevents ANR
            new Runnable() {
                @Override
                public void run() {
                    if (!Api.applySavedIptablesRules(context.getApplicationContext(),false)) {
                        // Error enabling firewall on boot
                        final Message msg = new Message();
                        msg.arg1 = R.string.toast_error_enabling;
                        toaster.sendMessage(msg);
                        Api.setEnabled(context.getApplicationContext(),false,false);
                    }
                }
            });
            // Start a new thread to enable the firewall - this prevents ANR
        }
        /*Intent i = new Intent(context,StartupService.class);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startService(i);*/
    }

你可以找到我的Api.java类here.

解决方法

12-26 08:39:27.116 I/ActivityManager(582): No longer want dev.ukanth.ufirewall (pid 2297): empty #17

此日志表示您已达到允许的最大空进程. (16是您的最大值)

更多关于empty processes的android doc:

A process that doesn’t hold any active application components. The only reason to keep this kind of process alive is for caching purposes,to improve startup time the next time a component needs to run in it. The system often kills these processes in order to balance overall system resources between process caches and the underlying kernel caches.

因此,不确定您的日志与您的iptables规则问题直接相关.

原文地址:https://www.jb51.cc/android/315860.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐