intent.addCategory(“android.intent.category.DEFAULT”);
intent.setDataAndType(
Uri.fromFile(new File(apk_path)),
“application/vnd.android.package-archive”);
startActivity(intent);
2.接收卸载应用程序的广播
AppUninstallReceiver receiver = new AppUninstallReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addDataScheme(“package”);
registerReceiver(receiver, filter);
-
相关广播
-
ACTION_PACKAGE_ADDED 一个新应用包已经安装在设备上,数据包括包名(最新安装的包程序不能接收到这个广播)
-
ACTION_PACKAGE_REPLACED 一个新版本的应用安装到设备,替换之前已经存在的版本
-
ACTION_PACKAGE_REMOVED 一个已存在的应用程序包已经从设备上移除,包括包名(正在被卸载的包程序不能接收到这个广播)
3.遍历集合时如何删除数据
方法一:高级for循环,记录要删除的数据,遍历后再删除
AppInfo deleteAppInfo = null;