android 卸载应用、打开应用、获得系统中已安装应用列表
首先:
1 、获得所有已经安装的应用的列表:List<ApplicationInfo> mApp = getPackageManager().getInstalledApplications(0)
2、删除指定的应用
Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.fromParts("package",mApp.get(i),null);
startActivity(intent);
3、打开指定应用
Intent reIntent = new Intent(Intent.ACTION_MAIN,null);
reIntent.addCategory(Intent.CATEGORY_LAUNCHER);
reIntent.setPackage(mApp.get(i).packageName);
List<ResolveInfo> resolve = getPackageManager().queryIntentActivities(reIntent,0);
if(resolve!=null && resolve.size()>0){
ResolveInfo res = resolve.get(0);
String apName = res.activityInfo.packageName;
String className = res.activityInfo.name;
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
ComponentName cptName = new ComponentName(apName,className);
intent.setComponent(cptName);
startActivity(intent);
}
更多相关文章
- android封装的menu自定义菜单列表
- Android(安卓)Listview之下拉刷新Wifi列表
- Android短信相关的常见协议
- 运用WindowManager,当滚动列表时显示一个类似Toast的提示(android
- Android列表组件ListView使用详解之数据为空提示信息
- Android展开/收缩列表 ExpandableListView 每次只能有一个项目是
- 【ListView】相关文章
- Android(安卓)AlertDialog对话框详解及实例
- Android(安卓)添加程序到桌面favorites列表