Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top