gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:17:36 25 4
gpt4 key购买 nike

我正在开发一个开源应用程序 (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来自安卓文档:

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 - 不再需要 ActivityManager - 不是服务问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14043442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com