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

前端之家收集整理的这篇文章主要介绍了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规则问题直接相关.

猜你在找的Android相关文章