作者:nissunshine | 来源:互联网 | 2023-09-18 14:50
安装:StringstrXXXX.apk;StringfileNameEnvironment.getExternalStorageDirectory()+str;Intenti
安装:String str = "/XXXX.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.demo.XXXX");
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);
Environment拥有一些可以获取环境变量的方法
,package:com.demo.XXXX这个形式是 package:程序完整的路径 (包名+程序名)。
Android 程序代码实现apk的安装和卸载,布布扣,bubuko.com