문제

I am trying to kill the background running applications using my application, but i unable to kill the process.

android.os.Process.killProcess(pid);
android.os.Process.sendSignal(pid,
android.os.Process.SIGNAL_KILL);
manager.killBackgroundProcesses(pid);

here pid is background running process id.

도움이 되었습니까?

해결책

Every Android app has its own user id, group id, and most of the time runs within its own process. So your app probably have no privilege to kill other process.

There is obviously a design flaw, you'd be better state out what actually you want to do.

다른 팁

Use this killBackgroundProcesses:

   try {
            ActivityManager actvityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
            actvityManager.killBackgroundProcesses(pkgn.toString());// pkgn is a process id /////
        } catch (Exception e) {
            e.printStackTrace();
        }

You also have to add this in manifest

<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top