vivo手机权限禁止--跳转至对应app的权限设置页面

vivo手机权限禁止–跳转至对应app的权限设置页面

	开始我用的这个方法在vivo 酷派,oopo上:(在vivo上已不能使用)

private void doStartApplicationWithPackageName(String packagename) {
// 通过包名获取此APP详细信息,包括Activities、services、versioncode、name等等
PackageInfo packageinfo = null;
try {
packageinfo = mContext.getPackageManager().getPackageInfo(packagename, 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (packageinfo == null) {
return;
}
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
resolveIntent.setPackage(packageinfo.packageName);
// 通过getPackageManager()的queryIntentActivities方法遍历
List resolveinfoList = mContext.getPackageManager()
.queryIntentActivities(resolveIntent, 0);
Log.e(“PermissionPageManager”, “resolveinfoList” + resolveinfoList.size());
for (int i = 0; i < resolveinfoList.size(); i++) {
Log.e(“PermissionPageManager”, resolveinfoList.get(i).activityInfo.packageName + resolveinfoList.get(i).activityInfo.name);
}
ResolveInfo resolveinfo = resolveinfoList.iterator().next();
if (resolveinfo != null) {
// packageName参数2 = 参数 packname
String packageName = resolveinfo.activityInfo.packageName;
// 这个就是我们要找的该APP的LAUNCHER的Activity[组织形式:packageName参数2.mainActivityname]
String className = resolveinfo.activityInfo.name;
// LAUNCHER Intent
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
// 设置ComponentName参数1:packageName参数2:MainActivity路径
ComponentName cn = new ComponentName(packageName, className);
intent.setComponent(cn);
try {
if (mContext.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
mContext.startActivity(intent);
}
} catch (Exception e) {
goIntentSetting();
e.printStackTrace();
}
}
}

下面这个方法完全满足需求
 /**
     * 
     * @param context  跳转至权限页面
     *       
     */
	private static void goVivoManager(Context context) {
    Intent localIntent;
    if (((Build.MODEL.contains("Y85")) && (!Build.MODEL.contains("Y85A"))) || (Build.MODEL.contains("vivo Y53L"))) {
        localIntent = new Intent();
        localIntent.setClassName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.PurviewTabActivity");
        localIntent.putExtra("packagename", context.getPackageName());
        localIntent.putExtra("tabId", "1");
        context.startActivity(localIntent);
    } else {
        localIntent = new Intent();
        localIntent.setClassName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.SoftPermissionDetailActivity");
        localIntent.setAction("secure.intent.action.softPermissionDetail");
        localIntent.putExtra("packagename", context.getPackageName());
        context.startActivity(localIntent);
    }
}

你可能感兴趣的:(权限,q,安卓基础)