2

Hi

How to kill all active processes from Android phone with code in my app? I read couple of articles like How to kill all running applications in android? and tried this code:

 List<ApplicationInfo> packages;

    PackageManager pm;
    pm = getPackageManager();
    //get a list of installed apps.
    packages = pm.getInstalledApplications(0);

    ActivityManager mActivityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);

    Log.d("Packages" , String.valueOf(packages));

    for (ApplicationInfo packageInfo : packages) {

        mActivityManager.killBackgroundProcesses(packageInfo.packageName);

        Log.d("Cleaned" , String.valueOf(packageInfo.packageName));

    }

Logcat does show me all the active processes, but no of them have closed/nothing happens.

Yes, I do have included this in my Manifest:

  <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />

I there something I'm missing?

Community
  • 1
  • 1
Onhar
  • 49
  • 1
  • 1
  • 7

0 Answers0