本文整理匯總了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;
}