Android examples for Activity:Activity Feature
force Stop Activity Package
//package com.java2s; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import android.app.ActivityManager; import android.content.Context; public class Main { public static void forceStopPackage(Context ctx, String packageName) { ActivityManager am = (ActivityManager) ctx .getSystemService(Context.ACTIVITY_SERVICE); Method method;/*from w w w. j av a 2s . c om*/ try { method = Class.forName("android.app.ActivityManager") .getMethod("forceStopPackage", String.class); method.invoke(am, packageName); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }