android apk 文件的安装和卸载代码:
都是通过intent 来完成
安装:
String str = "/com.xx.xxx.apk";
String fileName = Environment.getExternalStorageDirectory() + str;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
startActivity(intent);
卸载:
Uri packageURI = Uri.parse("package:com.xx.xxx");
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);
package:com.xx.xxx这个形式是 package:程序完整的路径 (包名+程序名).
Android应用安装与卸载
本文介绍了如何在Android设备上使用Java代码实现应用程序的安装与卸载操作。具体包括通过Intent启动系统默认的应用安装程序来安装指定路径的APK文件,以及通过Intent发起卸载指定包名的应用程序。
5万+

被折叠的 条评论
为什么被折叠?



