forceStopPackage应用中关闭其他应用程序
2016-01-12 20:17
260 查看
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
例如关闭打开的闹钟程序:
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
相关文章推荐
- Linux——file命令与magic file
- 命令行启动tomcat,怎么配置
- 从零开始搭建架构实施Android项目
- linux进程高cpu问题分析
- linux使用flock文件锁解决crontab冲突问题
- hadoop 1.2.1 安装配置
- linux添加用户和修改密码
- erlang的shell历史记录
- 如何更改linux文件的拥有者及用户组(chown和chgrp)
- linuxmint 执行 qmake 报错
- SSH Secure Shell Client 连接Linux 乱码
- string类--复制《copy()与copyTo()》
- Linux系统下卸载JDK 重新安装新版本
- Linux搭建 nfs 服务器
- 【MFC两种视频图像採集方法】DirectShow与Opencv
- Ubuntu下Apache、php、mysql默认安装路径
- Tomcat - SSL操作大全
- MFC (通过WM_COPYDATA消息) 进程间通信以及数据传递
- windows向linux传送文件
- linux opendir 和 readdir , closedir用法