Android安装或者卸载应用APK
16lz
2021-12-04
/** *启动安装APK * @author YOLANDA * @param path * @return */ public static void installApkByPath(Context context, String path){ Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(path)), Constants.INSTALL_MIMETYPE); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } /** * 启动卸载 * @author YOLANDA * @param context * @param oldpackage */ public static void uninstallApkByPackage(Context context, String oldpackage){ try { Uri packageURI = Uri.parse("package:" + oldpackage); Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI); context.startActivity(uninstallIntent); } catch (Exception e) { } }
更多相关文章
- Activity的启动流程
- Android(安卓)Studio安装app 报错的问题It is possible that thi
- 获取安装的应用
- android获取手机已经安装的app信息
- 指定浏览器访问指定页面(支持UC、Opera、QQ、Dolphin、Skyfire、
- 迈向Android的第一步 - 搭建Android开发环境
- android app 开启自动启动
- Android(安卓)静默安装
- Android(安卓)JNI环境搭建及开发入门