(原创)通过ActivityManager杀死第三方应用方式

ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); am.killBackgroundProcesses(responseAppInfo.getPackname()); Method forceStopPackage; try { baseLogShow("activation kill"); forceStopPackage = am.getClass(). getDeclaredMethod("forceStopPackage", String.class); forceStopPackage.setAccessible(true); try { forceStopPackage.invoke(am, responseAppInfo.getPackname()); } catch (IllegalAccessException e) { baseLogShow("activation kill IllegalAccessException" + e.toString()); e.printStackTrace(); } catch (InvocationTargetException e) { baseLogShow("activation kill InvocationTargetException" + e.toString()); e.printStackTrace(); } } catch (NoSuchMethodException e) { baseLogShow("activation kill NoSuchMethodException" + e.toString()); e.printStackTrace(); }


    推荐阅读