Android安装或者卸载应用APK

    /** *启动安装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) {
        }
    }

你可能感兴趣的:(安装,卸载,Android安装,Android卸载)