Android装配卸载APK(Intent)

Android安装卸载APK(Intent)

通过Intent机制,调出系统的安装卸载应用来安装卸载APK。

安装APK

        String apkPath = "file:///sdcard/download/downloadtest.apk";
        Uri uri=Uri.parse(apkPath);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "application/vnd.android.package-archive");
        startActivity(intent);

卸载APK

代码中的com.young.android是要卸载应用的包名

        Uri uri = Uri.parse("package:com.young.android");
        Intent intent = new Intent(Intent. ACTION_DELETE ,uri);
        startActivity(intent);


版权声明:本文为博主原创文章,未经博主允许不得转载。