List of usage examples for org.apache.cordova PermissionHelper hasPermission
public static boolean hasPermission(CordovaPlugin plugin, String permission)
From source file:com.microsoft.aad.adal.CordovaAdalPlugin.java
License:Open Source License
private void requestBrokerPermissions() { // USE_CREDENTIALS and MANAGE_ACOUNTS are deprecated and not required if (PermissionHelper.hasPermission(this, Manifest.permission.GET_ACCOUNTS)) { // android.permission.GET_ACCOUNTS // already granted callbackContext.success();// w w w . j av a 2 s . com return; } PermissionHelper.requestPermission(this, GET_ACCOUNTS_PERMISSION_REQ_CODE, Manifest.permission.GET_ACCOUNTS); }
From source file:com.tmantman.nativecamera.NativeCameraLauncher.java
License:Apache License
public void takePicture() { // Camera/*from www . j av a 2 s. co m*/ if (this.srcType == 1) { // Save the number of images currently on disk for later Intent intent = new Intent(this.cordova.getActivity().getApplicationContext(), CameraActivity.class); this.photo = createCaptureFile(); this.imageUri = Uri.fromFile(photo); intent.putExtra(MediaStore.EXTRA_OUTPUT, this.imageUri); this.cordova.startActivityForResult((CordovaPlugin) this, intent, 1); } else if ((this.srcType == 0) || (this.srcType == 2)) { // FIXME: Stop always requesting the permission if (!PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)) { PermissionHelper.requestPermission(this, SAVE_TO_ALBUM_SEC, Manifest.permission.READ_EXTERNAL_STORAGE); } else { this.getImage(this.srcType, this.destType, this.encodingType); } } }
From source file:com.whamads.nativecamera.NativeCameraLauncher.java
License:Apache License
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { PluginResult.Status status = PluginResult.Status.OK; String result = ""; this.callbackContext = callbackContext; try {//from ww w . j a va 2 s . co m if (action.equals("takePicture")) { if (!PermissionHelper.hasPermission(this, Manifest.permission.CAMERA)) { PermissionHelper.requestPermission(this, 1, Manifest.permission.CAMERA); } else { this.targetHeight = 0; this.targetWidth = 0; this.mQuality = 80; this.targetHeight = args.getInt(4); this.targetWidth = args.getInt(3); this.mQuality = args.getInt(0); this.takePicture(); PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT); r.setKeepCallback(true); callbackContext.sendPluginResult(r); } return true; } return false; } catch (JSONException e) { e.printStackTrace(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return true; } }
From source file:de.martinreinhardt.cordova.plugins.hotspot.HotSpotPlugin.java
License:Open Source License
public boolean hasPermissions() { for (String p : permissions) { if (!PermissionHelper.hasPermission(this, p)) { return false; }//from w ww . ja va2 s . c o m } return true; }
From source file:org.cloudsky.cordovaPlugins.BarcodeminCDV.java
License:BSD License
/** * check application's permissions// w ww. j a v a 2 s .c om */ public boolean hasPermisssion() { for (String p : permissions) { if (!PermissionHelper.hasPermission(this, p)) { return false; } } return true; }
From source file:pro.alyans.nativecamera.NativeCameraLauncher.java
License:Apache License
public void takePicture() { // Camera//from w ww .j a v a2s . c o m if (this.srcType == 1) { if (!PermissionHelper.hasPermission(this, Manifest.permission.CAMERA)) { PermissionHelper.requestPermission(this, TAKE_PIC_SEC, Manifest.permission.CAMERA); } else { // Save the number of images currently on disk for later Intent intent = new Intent(this.cordova.getActivity().getApplicationContext(), CameraActivity.class); this.photo = createCaptureFile(); this.imageUri = Uri.fromFile(photo); intent.putExtra(MediaStore.EXTRA_OUTPUT, this.imageUri); this.cordova.startActivityForResult((CordovaPlugin) this, intent, 1); } } else if ((this.srcType == 0) || (this.srcType == 2)) { // FIXME: Stop always requesting the permission if (!PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)) { PermissionHelper.requestPermission(this, SAVE_TO_ALBUM_SEC, Manifest.permission.READ_EXTERNAL_STORAGE); } else { this.getImage(this.srcType, this.destType, this.encodingType); } } }