com.facebook.react.modules.core.PermissionAwareActivity Java Examples
The following examples show how to use
com.facebook.react.modules.core.PermissionAwareActivity.
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: RNLBarCodeScannerView.java From react-native-barcode with MIT License | 6 votes |
public void setup() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (mContext.checkSelfPermission(mCameraPermission) != PackageManager.PERMISSION_GRANTED) { PermissionAwareActivity activity = (PermissionAwareActivity) mContext.getCurrentActivity(); if (activity != null) { activity.requestPermissions(new String[]{mCameraPermission}, PERMISSION_REQUEST_CODE, this); return; } errorCallback(RNLBarCodeError.NoCameraPermission.getCode(), "Don't authorize use camera"); return; } } open(); if (!this.enable) { addFrameProcessor(mFrameProcessor); } }
Example #2
Source File: Web3WebviewModule.java From react-native-web3-webview with MIT License | 6 votes |
public boolean grantFileDownloaderPermissions() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { return true; } boolean result = true; if (ContextCompat.checkSelfPermission(getCurrentActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { result = false; } if (!result) { PermissionAwareActivity activity = getPermissionAwareActivity(); activity.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, FILE_DOWNLOAD_PERMISSION_REQUEST, webviewFileDownloaderPermissionListener); } return result; }
Example #3
Source File: GPSStateModule.java From react-native-gps-state with MIT License | 6 votes |
@ReactMethod public void requestAuthorization() { if (_NativeIsDeviceMOrAbove()) { String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION}; Activity activity = getCurrentActivity(); int requestCode = REQUEST_CODE_AUTHORIZATION; if (activity instanceof ReactActivity) { ((ReactActivity) activity).requestPermissions(permissions, requestCode, listener); } else if (activity instanceof PermissionAwareActivity) { ((PermissionAwareActivity) activity).requestPermissions(permissions, requestCode, listener); } else { ActivityCompat.requestPermissions(activity, permissions, requestCode); } } }
Example #4
Source File: CustomWebViewModule.java From react-native-webview-android-file-upload with MIT License | 5 votes |
@TargetApi(Build.VERSION_CODES.M) private void requestPermissions() { if (getCurrentActivity() instanceof ReactActivity) { ((ReactActivity) getCurrentActivity()).requestPermissions(new String[]{ Manifest.permission.CAMERA}, REQUEST_CAMERA, listener); } else { ((PermissionAwareActivity) getCurrentActivity()).requestPermissions(new String[]{ Manifest.permission.CAMERA}, REQUEST_CAMERA, listener); } }
Example #5
Source File: Web3WebviewModule.java From react-native-web3-webview with MIT License | 5 votes |
private PermissionAwareActivity getPermissionAwareActivity() { Activity activity = getCurrentActivity(); if (activity == null) { throw new IllegalStateException("Tried to use permissions API while not attached to an Activity."); } else if (!(activity instanceof PermissionAwareActivity)) { throw new IllegalStateException("Tried to use permissions API but the host Activity doesn't implement PermissionAwareActivity."); } return (PermissionAwareActivity) activity; }
Example #6
Source File: PermissionsModule.java From react-native-GPay with MIT License | 5 votes |
private PermissionAwareActivity getPermissionAwareActivity() { Activity activity = getCurrentActivity(); if (activity == null) { throw new IllegalStateException("Tried to use permissions API while not attached to an " + "Activity."); } else if (!(activity instanceof PermissionAwareActivity)) { throw new IllegalStateException("Tried to use permissions API but the host Activity doesn't" + " implement PermissionAwareActivity."); } return (PermissionAwareActivity) activity; }