本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例10: shouldShowRequestPermissionRationale
import android.app.Activity; //导入方法依赖的package包/类
public static boolean shouldShowRequestPermissionRationale(Activity activity, String permissions) {
return activity.shouldShowRequestPermissionRationale(permissions);
}
示例11: shouldShowRequestPermissionRationale
import android.app.Activity; //导入方法依赖的package包/类
public static boolean shouldShowRequestPermissionRationale(Activity activity, String permission) {
return activity.shouldShowRequestPermissionRationale(permission);
}
示例12: shouldShowRational
import android.app.Activity; //导入方法依赖的package包/类
public static boolean shouldShowRational(Activity activity, String permission) {
if (useRunTimePermissions()) {
return activity.shouldShowRequestPermissionRationale(permission);
}
return false;
}