安装某个apk文件:

String fileName = "/sdcard/tmp.apk";
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(new File(fileName) ), "application/vnd.android.package-archive");
startActivity(i);


注:如果文件不存在会提示解析出错

卸载某个程序:

Uri packageURI = Uri.parse("package:com.aslibra.test");
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);


参考阅读:

Install and Uninstall Android applications with PackageInstaller,包含判断是否开启安装第三方程序的支持

另外还有 Android Intent的几种用法全面总结,必要的时候可以参考啦




原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
Tags:
发表评论
表情
emotemotemotemotemotemotemotemotemotemotemotemotemot
emotemotemotemotemotemotemotemotemotemotemotemot
打开HTML 打开UBB 打开表情 隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写
 

阅读推荐

服务器相关推荐

开发相关推荐

应用软件推荐