本文整理匯總了Java中android.support.v4.content.PermissionChecker.PERMISSION_DENIED屬性的典型用法代碼示例。如果您正苦於以下問題:Java PermissionChecker.PERMISSION_DENIED屬性的具體用法?Java PermissionChecker.PERMISSION_DENIED怎麽用?Java PermissionChecker.PERMISSION_DENIED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.support.v4.content.PermissionChecker
的用法示例。
在下文中一共展示了PermissionChecker.PERMISSION_DENIED屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onRequestPermissionsResult
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case REQUEST_CAMERA:
for (int i = 0; i < permissions.length; i++) {
if (grantResults[i] == PermissionChecker.PERMISSION_DENIED) {
String reason = permissions[i] + " is denied !";
T.showLToast(mContext, reason);
return;
}
}
openCamera();
break;
default:
break;
}
}
示例2: createFloatingWindow
private void createFloatingWindow() {
//檢查權限,低於6.0
int p = PermissionChecker.checkSelfPermission(this, Manifest.permission.SYSTEM_ALERT_WINDOW);
if (p == PermissionChecker.PERMISSION_DENIED) {
Toast.makeText(this, "缺少懸浮窗權限,請配置權限", Toast.LENGTH_SHORT).show();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[]{Manifest.permission.SYSTEM_ALERT_WINDOW}, 0);
}
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//大於6.0
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
startActivity(intent);
} else {
floatingWindow = new FloatingWindow(this);
}
} else {
floatingWindow = new FloatingWindow(this);
}
}
}
示例3: isWriteSettingsGranted
public static boolean isWriteSettingsGranted(@NonNull Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int result = PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.WRITE_SETTINGS);
if ((result == PermissionChecker.PERMISSION_GRANTED) || Settings.System.canWrite(context)) {
return true;
} else if (result == PermissionChecker.PERMISSION_DENIED) {
return false;
} else {
return false;
}
}else {
return true;
}
}
示例4: hasPermission
private boolean hasPermission(String[] permissions) {
for (String permission : permissions) {
if (ContextCompat.checkSelfPermission(mContext, permission) == PermissionChecker.PERMISSION_DENIED) {
return false;
}
}
return true;
}