forceStopPackage应用中关闭其他应用程序

android4.0在某应用中关闭其他应用程序:
例如关闭打开的闹钟程序:
  String pakageName = "com.android.BBKClock"; 
  ActivityManager activityMgr;
  activityMgr = (ActivityManager)mContext.getSystemService(
  Context.ACTIVITY_SERVICE);
  activityMgr.forceStopPackage(packageName);


在应用AndroidManifest.xml中添加权限:
  application标签中加上:
    android:sharedUserId="android.uid.system"
  manifest标签中添加权限:
    <uses-permission android:name="android.permission.FORCE_STOP_PACKAGES"/>

  android:sharedUserId="android.uid.system"将使应用运行在系统进程中,共享系统进程的数据,
  具有系统进程的权限。这可能带来的负面不确定问题不得而知了。 

  android.uid.system属性的进程 须要在android.mk里这样设置:

  LOCAL_CERTIFICATE := platform

原文地址:https://www.cnblogs.com/zhengtu2015/p/5125495.html