Domanda

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.

È stato utile?

Soluzione

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.

Altri suggerimenti

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" />
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top