ActivityManager mAm = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
mAm.forceStopPackage("xxx.xxx.xxx");需要添加权限:
<uses-permission android:name="android.permission.FORCE_STOP_PACKAGES"/>
试试好使么?
mAm.forceStopPackage("xxx.xxx.xxx");需要添加权限:
<uses-permission android:name="android.permission.FORCE_STOP_PACKAGES"/>
试试好使么?
解决方案 »
- SDK Manager : Failed to create the SD card.
- android做游戏 背景图片移动问题
- android下的jni问题
- Android手机摔了一下,开机不了卡在开机动画那里,怎样把里面的照片信息等取出来
- Where is doc about android widget?
- 真机Nexus4,adb shell 问题:device not found
- 使用transmission开发bt下载客户端
- gridview里图片过大,出现oom问题,咋样处理?
- 如何设置GridView视图的图片大小?
- Android中WebView打开网页问题
- 安卓继承SurfaceView重写surfaceCreated 怎么找不到
- 使用百度云推送SDK 报错,求救
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
am.killBackgroundProcesses(getPackageName()); //应用的包名
需要加入获取包名的权限:<uses-permission android:name="android.permission.RESTART_PACKAGES"/>
第二种
int myPid = android.os.Process.myPid(); //获取当前进程的id
android.os.Process.killProcess(myPid);
int myPid = android.os.Process.myPid(); //获取当前进程的id
android.os.Process.killProcess(myPid);
这个只能杀死自己。黑马的anroid手机安全卫士项目里面有类似的功能,获取当前运行的app,并停止运行。
你搜搜很多。