How to install/update/remove APK using “PackageInstaller” class in Android L?

前端 未结 7 2241
长发绾君心
长发绾君心 2020-11-30 23:22

Plz check below classe & give me the suggestion for how to use them https://developer.android.com/reference/android/content/pm/PackageInstaller.html https://developer.an

7条回答
  •  无人及你
    2020-11-30 23:31

    INSTALL:

    Intent promptInstall = new Intent(Intent.ACTION_VIEW);
            promptInstall.setDataAndType(Uri.fromFile(new File(Environment
                    .getExternalStorageDirectory() + "/download/" + APK_NAME)),
                    "application/vnd.android.package-archive");
            promptInstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(promptInstall);
    

    UNINSTALL:

    Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package",
    getPackageManager().getPackageArchiveInfo(apkUri.getPath(), 0).packageName,null));
    startActivity(intent);
    

提交回复
热议问题