Tuesday, June 30, 2015

Kill the applications running in background in android

Use this in Activity Class to  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" />

No comments:

Post a Comment