Java Code Examples for org.apache.cordova.PermissionHelper#hasPermission()

The following examples show how to use org.apache.cordova.PermissionHelper#hasPermission() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SaveImage.java    From SaveImage with MIT License 6 votes vote down vote up
/**
 * Check saveImage arguments and app permissions
 *
 * @param args              JSON Array of args
 * @param callbackContext   callback id for optional progress reports
 *
 * args[0] filePath         file path string to image file to be saved to gallery
 */  
private void saveImageToGallery(JSONArray args, CallbackContext callback) throws JSONException {
	this.filePath = args.getString(0);
	this.callbackContext = callback;
    Log.d("SaveImage", "SaveImage in filePath: " + filePath);
    
    if (filePath == null || filePath.equals("")) {
    	callback.error("Missing filePath");
        return;
    }
    
    if (PermissionHelper.hasPermission(this, WRITE_EXTERNAL_STORAGE)) {
    	Log.d("SaveImage", "Permissions already granted, or Android version is lower than 6");
    	performImageSave();
    } else {
    	Log.d("SaveImage", "Requesting permissions for WRITE_EXTERNAL_STORAGE");
    	PermissionHelper.requestPermission(this, WRITE_PERM_REQUEST_CODE, WRITE_EXTERNAL_STORAGE);
    }      
}
 
Example 2
Source File: BackgroundDownload.java    From cordova-plugin-background-download with Apache License 2.0 5 votes vote down vote up
private boolean checkPermissions(JSONArray args, CallbackContext callbackContext) {
    if (!PermissionHelper.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
        permissionRequests.put(permissionRequests.size(), new PermissionsRequest(args, callbackContext));
        PermissionHelper.requestPermission(this, permissionRequests.size() - 1, Manifest.permission.WRITE_EXTERNAL_STORAGE);
        return false;
    }

    return true;
}
 
Example 3
Source File: GeolocationPlugin.java    From cordova-plugin-baidu-geolocation with MIT License 5 votes vote down vote up
/**
 * 判断是否有对应权限
 */
public boolean hasPermisssion() {
    for(String p : permissions)
    {
        if(!PermissionHelper.hasPermission(this, p))
        {
            return false;
        }
    }
    return true;
}
 
Example 4
Source File: Flashlight.java    From Flashlight-PhoneGap-Plugin with MIT License 5 votes vote down vote up
public boolean hasPermisssion() {
  for (final String p : permissions) {
    if (!PermissionHelper.hasPermission(this, p)) {
      return false;
    }
  }
  return true;
}
 
Example 5
Source File: FileUtils.java    From keemob with MIT License 4 votes vote down vote up
private boolean hasReadPermission() {
    return PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
}
 
Example 6
Source File: FileUtils.java    From keemob with MIT License 4 votes vote down vote up
private boolean hasWritePermission() {
    return PermissionHelper.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
 
Example 7
Source File: FileUtils.java    From keemob with MIT License 4 votes vote down vote up
private boolean hasReadPermission() {
    return PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
}
 
Example 8
Source File: FileUtils.java    From keemob with MIT License 4 votes vote down vote up
private boolean hasWritePermission() {
    return PermissionHelper.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
 
Example 9
Source File: FileUtils.java    From keemob with MIT License 4 votes vote down vote up
private boolean hasReadPermission() {
    return PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
}
 
Example 10
Source File: FileUtils.java    From keemob with MIT License 4 votes vote down vote up
private boolean hasWritePermission() {
    return PermissionHelper.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
 
Example 11
Source File: FileUtils.java    From reacteu-app with MIT License 4 votes vote down vote up
private boolean hasReadPermission() {
    return PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
}
 
Example 12
Source File: FileUtils.java    From reacteu-app with MIT License 4 votes vote down vote up
private boolean hasWritePermission() {
    return PermissionHelper.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}