Pregunta

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.

¿Fue útil?

Solución

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.

Otros consejos

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" />
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top