android跳转权限设置页面

/**
     * 华为
     */
    private static void goHuaWeiMainager(Context context) {
        try {
            Intent intent = new Intent(BuildConfig.mainApplicationId);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            ComponentName comp = new ComponentName("com.huawei.systemmanager", "com.huawei.permissionmanager.ui.MainActivity");
            intent.setComponent(comp);
            context.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
            goIntentSetting(context);
        }
    }

    /**
     * 小米
     */
    private static void goXiaoMiMainager(Context context) {
        String rom_version = RomUtil.getProp(KEY_VERSION_MIUI);
        if ("V6".equals(rom_version) || "V7".equals(rom_version)) {
            try {
                Intent intent = new Intent();
                intent.setAction("miui.intent.action.APP_PERM_EDITOR");
                intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
                intent.putExtra("extra_pkgname", BuildConfig.mainApplicationId);
                context.startActivity(intent);
            } catch(Exception e) {
                e.printStackTrace();
                goIntentSetting(context);
            }
        } else if ("V8".equals(rom_version) || "V9".equals(rom_version)) {
            try {
                Intent intent = new Intent();
                intent.setAction("miui.intent.action.APP_PERM_EDITOR");
                intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.PermissionsEditorActivity");
                intent.putExtra("extra_pkgname", BuildConfig.mainApplicationId);
                context.startActivity(intent);
            } catch(Exception e) {
                e.printStackTrace();
                goIntentSetting(context);
            }
        } else {
            goIntentSetting(context);
        }
    }

    /**
     * 魅族
     */
    private static void goMeizuMainager(Context context) {
        try {
            Intent intent = new Intent("com.meizu.safe.security.SHOW_APPSEC");
            intent.addCategory(Intent.CATEGORY_DEFAULT);
            intent.putExtra("packageName", BuildConfig.mainApplicationId);
            context.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
            goIntentSetting(context);
        }
    }

    /**
     * 其他
     */
    private static void goIntentSetting(Context context) {
        Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        Uri uri = Uri.fromParts("package", BuildConfig.mainApplicationId, null);
        intent.setData(uri);
        try {
            context.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

你可能感兴趣的:(Android)