本文整理了Java中android.app.Activity.shouldShowRequestPermissionRationale()
方法的一些代码示例,展示了Activity.shouldShowRequestPermissionRationale()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.shouldShowRequestPermissionRationale()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:shouldShowRequestPermissionRationale
暂无
代码示例来源:origin: naman14/Timber
public static boolean shouldShowRequestPermissionRationale(Activity activity, String permissions) {
return activity.shouldShowRequestPermissionRationale(permissions);
}
代码示例来源:origin: aa112901/remusic
public static boolean shouldShowRequestPermissionRationale(Activity activity, String permissions) {
return activity.shouldShowRequestPermissionRationale(permissions);
}
代码示例来源:origin: bluelinelabs/Conductor
/**
* Gets whether you should show UI with rationale for requesting a permission.
* {@see android.app.Activity#shouldShowRequestPermissionRationale(String)}
*
* @param permission A permission this Controller has requested
*/
public boolean shouldShowRequestPermissionRationale(@NonNull String permission) {
return Build.VERSION.SDK_INT >= 23 && getActivity().shouldShowRequestPermissionRationale(permission);
}
代码示例来源:origin: pili-engineering/PLDroidPlayer
if (!mActivity.shouldShowRequestPermissionRationale(permissionsList.get(0))) {
showMessageOKCancel(message,
new DialogInterface.OnClickListener() {
代码示例来源:origin: jokermonn/permissions4m
@SuppressWarnings("unchecked")
@SuppressLint("NewApi")
void tryRequestWithAnnotation() {
int requestCode = getRequestCode();
if ((getActivity()).shouldShowRequestPermissionRationale(getRequestPermission())) {
Object context = getContext();
if (!getProxy(context.getClass().getName()).customRationale(getActivity(),
requestCode)) {
getProxy(context.getClass().getName()).rationale(getActivity(), requestCode);
ActivityCompat.requestPermissions(getActivity(), new String[]{getRequestPermission()},
requestCode);
}
} else {
ActivityCompat.requestPermissions(getActivity(), new String[]{getRequestPermission()},
requestCode);
}
}
代码示例来源:origin: pili-engineering/PLDroidShortVideo
if (!mActivity.shouldShowRequestPermissionRationale(permissionsList.get(0))) {
showMessageOKCancel(message,
new DialogInterface.OnClickListener() {
代码示例来源:origin: CesarValiente/PermissionsSample
@Override
public boolean shouldShowRequestPermissionRationale(String permission) {
return activity.shouldShowRequestPermissionRationale(permission);
}
}
代码示例来源:origin: xuningjack/RequestPermission
public static boolean shouldShowRequestPermissionRationale(Activity activity,
String permission) {
return activity.shouldShowRequestPermissionRationale(permission);
}
代码示例来源:origin: iqiyi/Neptune
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public boolean shouldShowRequestPermissionRationale(java.lang.String string0) {
return mOriginActivity.shouldShowRequestPermissionRationale(string0);
}
代码示例来源:origin: brainysoon/cyberCar
@TargetApi(23)
public static boolean shouldShowRequestPermissionRationale(Activity activity, String permissions) {
return activity.shouldShowRequestPermissionRationale(permissions);
}
代码示例来源:origin: rohanoid5/Muzesto
@TargetApi(Build.VERSION_CODES.M)
public static boolean shouldShowRequestPermissionRationale(Activity activity, String permissions) {
return activity.shouldShowRequestPermissionRationale(permissions);
}
代码示例来源:origin: adorsys/sms-parser-android
@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);
}
}
}
代码示例来源:origin: LuckSiege/PictureSelectorLight
@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;
}
代码示例来源:origin: ChangWeiBa/AesExoPlayer
@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;
}
代码示例来源:origin: jksiezni/permissive
/**
* @param activity An Activity is required here.
* @param permissions An array of permissions to be checked.
* @return An array of permissions that may require a rationale to be shown.
*/
static String[] getPermissionsRequiringRationale(Activity activity, String[] permissions) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
final List<String> rationalePermissions = new ArrayList<>();
for (String permission : permissions) {
if (checkPermissionInt(activity, permission) == PackageManager.PERMISSION_DENIED
&& activity.shouldShowRequestPermissionRationale(permission)) {
rationalePermissions.add(permission);
}
}
return rationalePermissions.toArray(new String[rationalePermissions.size()]);
}
return new String[0];
}
代码示例来源:origin: akshay2211/PixImagePicker
@RequiresApi(api = Build.VERSION_CODES.M)
private static boolean addPermission(List<String> permissionsList, String permission, Activity ac) {
if (ac.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
permissionsList.add(permission);
// Check for Rationale Option
return ac.shouldShowRequestPermissionRationale(permission);
}
return true;
}
代码示例来源:origin: yxping/EasyPermissionUtil
/**
* 检查单个权限是否被允许,(当应用第一次安装的时候,不会有rational的值,此时返回均是denied)
*
* @param permission The name of the permission being checked.
* @return PermissionUtil.PERMISSION_GRANTED / PERMISSION_DENIED / PERMISSION_RATIONAL or {@code null}
* if context is not instanceof Activity.
*/
@TargetApi(Build.VERSION_CODES.M)
public int checkSinglePermission(String permission) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return PERMISSION_GRANTED;
}
if (mActivity == null) {
mActivity = getTopActivity();
}
if (mActivity != null) {
if (mActivity.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED) {
return PERMISSION_GRANTED;
} else {
if (mActivity.shouldShowRequestPermissionRationale(permission)) {
return PERMISSION_RATIONAL;
} else {
return PERMISSION_DENIED;
}
}
} else {
Log.e(TAG, "TopActivity not find");
return -1;
}
}
代码示例来源:origin: tangpeng/EsayPermissions
/**
* 检查某个权限是否被永久拒绝
*
* @param activity Activity对象
* @param permission 请求的权限
*/
static boolean checkSinglePermissionPermanentDenied(Activity activity, String permission) {
//安装权限和浮窗权限不算,本身申请方式和危险权限申请方式不同,因为没有永久拒绝的选项,所以这里返回false
if (permission.equals(Permission.REQUEST_INSTALL_PACKAGES) || permission.equals(Permission.SYSTEM_ALERT_WINDOW)) {
return false;
}
//检测8.0的两个新权限
if (permission.equals(Permission.ANSWER_PHONE_CALLS) || permission.equals(Permission.READ_PHONE_NUMBERS)) {
//检查当前的安卓版本是否符合要求
if (!isOverOreo()) {
return false;
}
}
if (PermissionUtils.isOverMarshmallow()) {
if (activity.checkSelfPermission(permission) == PackageManager.PERMISSION_DENIED &&
!activity.shouldShowRequestPermissionRationale(permission)) {
return true;
}
}
return false;
}
代码示例来源:origin: pili-engineering/QNRTC-Android
if (!mActivity.shouldShowRequestPermissionRationale(permissionsList.get(0))) {
showMessageOKCancel(message,
new DialogInterface.OnClickListener() {
代码示例来源:origin: jahirfiquitiva/IconShowcase
if (((Activity) context).shouldShowRequestPermissionRationale(permission)) {
if (requestListener != null) requestListener.onPermissionDenied();
} else {
内容来源于网络,如有侵权,请联系作者删除!