安装 apk:
Intent i = new Intent(Intent.ACTION_VIEW);
String filePath = appInfo.getAbsolutePath();
i.setDataAndType(Uri.parse("file://" + filePath),
"application/vnd.android.package-archive");
startActivity(i);
卸载 apk:
Uri uri = Uri.fromParts("package",
appList.get(pos).getPackageName(),
null);
Intent intentuninstall = new Intent(Intent.ACTION_DELETE, uri);
startActivity(intentuninstall);
本文介绍了如何在Android设备上安装和卸载应用程序的方法。通过Intent实现安装功能,并使用特定的URI和Intent.ACTION_VIEW来触发安装流程。对于卸载操作,则通过创建指向包名的URI并设置Intent.ACTION_DELETE来实现。
147

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



