當前位置: 首頁>>代碼示例>>Java>>正文


Java PermissionChecker.PERMISSION_DENIED屬性代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:REBOOTERS,項目名稱:AndroidAnimationExercise,代碼行數:18,代碼來源:CameraActivity.java

示例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);
        }

    }

}
 
開發者ID:cjh1005221032,項目名稱:FloatingWindow,代碼行數:26,代碼來源:MainActivity.java

示例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;
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:14,代碼來源:permissionManager.java

示例4: hasPermission

private boolean hasPermission(String[] permissions) {
    for (String permission : permissions) {
        if (ContextCompat.checkSelfPermission(mContext, permission) == PermissionChecker.PERMISSION_DENIED) {
            return false;
        }
    }
    return true;
}
 
開發者ID:REBOOTERS,項目名稱:AndroidAnimationExercise,代碼行數:8,代碼來源:CameraActivity.java


注:本文中的android.support.v4.content.PermissionChecker.PERMISSION_DENIED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。