Java tutorial
//package com.java2s; import android.app.ActivityManager; import android.content.Context; import java.lang.reflect.Method; public class Main { public static void killProcesses(Context context, int pid, String processName) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); String packageName; try { if (!processName.contains(":")) { packageName = processName; } else { packageName = processName.split(":")[0]; } activityManager.killBackgroundProcesses(packageName); Method forceStopPackage = activityManager.getClass().getDeclaredMethod("forceStopPackage", String.class); forceStopPackage.setAccessible(true); forceStopPackage.invoke(activityManager, packageName); } catch (Exception e) { e.printStackTrace(); } } }