当前位置: 首页>>代码示例>>Java>>正文


Java Activity.shouldShowRequestPermissionRationale方法代码示例

本文整理汇总了Java中android.app.Activity.shouldShowRequestPermissionRationale方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.shouldShowRequestPermissionRationale方法的具体用法?Java Activity.shouldShowRequestPermissionRationale怎么用?Java Activity.shouldShowRequestPermissionRationale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.shouldShowRequestPermissionRationale方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findPermissionResult

import android.app.Activity; //导入方法依赖的package包/类
@TargetApi(value = Build.VERSION_CODES.M)
private static List<MPermissionResultEnum> findPermissionResult(Activity activity, String... permissions) {
    boolean overM = isOverMarshmallow();
    List<MPermissionResultEnum> result = new ArrayList<>();
    for (String p : permissions) {
        if (overM) {
            if (activity.checkSelfPermission(p) == PackageManager.PERMISSION_GRANTED) {
                result.add(MPermissionResultEnum.GRANTED);
            } else {
                if (!activity.shouldShowRequestPermissionRationale(p)) {
                    result.add(MPermissionResultEnum.DENIED_NEVER_ASK_AGAIN);
                } else {
                    result.add(MPermissionResultEnum.DENIED);
                }
            }
        } else {
            result.add(MPermissionResultEnum.GRANTED);
        }
    }

    return result;
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:23,代码来源:BaseMPermission.java

示例2: getPermission

import android.app.Activity; //导入方法依赖的package包/类
@TargetApi(M)
static private void getPermission(String[] permissions,Activity activity) {
    if(Build.VERSION.SDK_INT>=23) {
        ArrayList<String> preToDo = new ArrayList<>();
        boolean tip = false;
        for (String pre : permissions) {
            if (activity.checkSelfPermission(pre) != PackageManager.PERMISSION_GRANTED) {
                preToDo.add(pre);
                if (activity.shouldShowRequestPermissionRationale(pre)) {
                    tip = true;
                }
            }
        }
        if (preToDo.size() == 0)
            return;
        if (tip)
            showToast(sContext.getString(R.string.permissions_need));
        activity.requestPermissions(preToDo.toArray(new String[preToDo.size()]), 0);
    }
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:21,代码来源:LaunchService.java

示例3: shouldShowRequestPermissionRationaleImplementation

import android.app.Activity; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.M)
private boolean shouldShowRequestPermissionRationaleImplementation(final Activity activity, final String... permissions) {
    for (String p : permissions) {
        if (!isGranted(p) && !activity.shouldShowRequestPermissionRationale(p)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:ChangWeiBa,项目名称:AesExoPlayer,代码行数:10,代码来源:RxPermissions.java

示例4: shouldShowRequestPermissionRationale

import android.app.Activity; //导入方法依赖的package包/类
private boolean shouldShowRequestPermissionRationale(Activity activity, String permission) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        return false;
    } else {
        return activity.shouldShowRequestPermissionRationale(permission);
    }
}
 
开发者ID:weex-plugins,项目名称:weex-permissions,代码行数:8,代码来源:PermissionsModule.java

示例5: requestPermission

import android.app.Activity; //导入方法依赖的package包/类
public static void requestPermission(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (activity.shouldShowRequestPermissionRationale(PERMISSION_CAMERA)
                || activity.shouldShowRequestPermissionRationale(PERMISSION_STORAGE)) {
            Toast.makeText(activity, "Need camera and storage permissions to continue",
                    Toast.LENGTH_LONG).show();
        }
        activity.requestPermissions(new String[]{PERMISSION_CAMERA,
                PERMISSION_STORAGE}, PERMISSIONS_REQUEST);
    }
}
 
开发者ID:deepenai,项目名称:deepenlib-android-sample,代码行数:12,代码来源:PermissionUtil.java

示例6: shouldShowRequestPermissionRationale

import android.app.Activity; //导入方法依赖的package包/类
private boolean shouldShowRequestPermissionRationale(Activity activity,
                                                     String permission) {
    if (Build.VERSION.SDK_INT >= 23) {
        return activity.shouldShowRequestPermissionRationale(permission);
    }
    return false;
}
 
开发者ID:villela,项目名称:flutter_qrcode_reader,代码行数:8,代码来源:QRCodeReaderPlugin.java

示例7: requestSMSPermission

import android.app.Activity; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.M)
public static void requestSMSPermission(@NonNull Activity activity) {
    final String permission = Manifest.permission.RECEIVE_SMS;
    int hasSpecificPermission = ContextCompat.checkSelfPermission(activity, permission);
    if (hasSpecificPermission != PackageManager.PERMISSION_GRANTED
            && !activity.shouldShowRequestPermissionRationale(permission)) {
        activity.requestPermissions(new String[]{permission},
                REQUEST_CODE_ASK_PERMISSIONS);
    }
}
 
开发者ID:adorsys,项目名称:sms-parser-android,代码行数:11,代码来源:SmsTool.java

示例8: hasAlwaysDeniedPermission

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 是否彻底拒绝了某项权限
 */
@TargetApi(Build.VERSION_CODES.M)
private static boolean hasAlwaysDeniedPermission(Activity activity, String... deniedPermissions) {
    try {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return false;
        boolean rationale;
        for (String permission : deniedPermissions) {
            rationale = activity.shouldShowRequestPermissionRationale(permission);
            if (!rationale) return true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:lennyup,项目名称:react-native-udesk,代码行数:18,代码来源:XPermissionUtils.java

示例9: isPermissionDenyWithNeverAsk

import android.app.Activity; //导入方法依赖的package包/类
/**
 * use for check permission is deny with never ask again
 *
 * @param activity
 * @param permission
 * @return
 */
private static boolean isPermissionDenyWithNeverAsk(Activity activity, String permission) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (isPermissionDenied(activity, permission)) {
            boolean reational = activity.shouldShowRequestPermissionRationale(permission);
            //Utils.printLog(permission + ", reatianal=" + reational);
            return reational;
        }
    }
    return false;
}
 
开发者ID:NarendraSickarwar,项目名称:FirebasePost,代码行数:18,代码来源:PermissionsHelper.java

示例10: shouldShowRequestPermissionRationale

import android.app.Activity; //导入方法依赖的package包/类
public static boolean shouldShowRequestPermissionRationale(Activity activity, String permissions) {
    return activity.shouldShowRequestPermissionRationale(permissions);
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:4,代码来源:Nammu.java

示例11: shouldShowRequestPermissionRationale

import android.app.Activity; //导入方法依赖的package包/类
public static boolean shouldShowRequestPermissionRationale(Activity activity, String permission) {
    return activity.shouldShowRequestPermissionRationale(permission);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:ActivityCompatApi23.java

示例12: shouldShowRational

import android.app.Activity; //导入方法依赖的package包/类
public static boolean shouldShowRational(Activity activity, String permission) {
    if (useRunTimePermissions()) {
        return activity.shouldShowRequestPermissionRationale(permission);
    }
    return false;
}
 
开发者ID:marcoscgdev,项目名称:EasyPermissions,代码行数:7,代码来源:EasyPermissions.java


注:本文中的android.app.Activity.shouldShowRequestPermissionRationale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。