當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。