gpt4 book ai didi

android - 为什么 KILL_BACKGROUND_PROCESSES 不起作用?

转载 作者:太空狗 更新时间:2023-10-29 15:38:52 26 4
gpt4 key购买 nike

<分区>

在 AndroidManifest.xml 中,我有这个权限:

<user-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />

但我仍然收到错误消息:

Permission Denial: killBackgroundProcesses() from ... requires android.permission.KILL_BACKGROUND_PROCESSES

此方法调用自:

    ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
final List<RunningAppProcessInfo> runningProcesses = am.getRunningAppProcesses();
for(RunningAppProcessInfo runningProcess : runningProcesses) {
if(runningProcess.processName.equals("com.example.nihao")) {
Log.v("Hello", "kill process "+runningProcess.pid);
//android.os.Process.killProcess(runningProcess.pid);
am.killBackgroundProcesses("com.example.nihao");
}
}

有什么线索吗?

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