Java Code Examples for android.support.v13.app.FragmentCompat#requestPermissions()

The following examples show how to use android.support.v13.app.FragmentCompat#requestPermissions() . 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: BaseFragment.java    From Learning-Resources with MIT License 6 votes vote down vote up
/**
 * Ask Permission to be granted.
 *
 * @param permissionAsk
 */
private void internalRequestPermission(String[] permissionAsk) {
    String arrayPermissionNotGranted[];
    ArrayList<String> permissionsNotGranted = new ArrayList<>();

    for (String aPermissionAsk : permissionAsk) {
        if (!isPermissionGranted(getActivity(), aPermissionAsk)) {
            permissionsNotGranted.add(aPermissionAsk);
        }
    }

    if (permissionsNotGranted.isEmpty()) {

        if (permissionResult != null)
            permissionResult.permissionGranted();

    } else {

        arrayPermissionNotGranted = new String[permissionsNotGranted.size()];
        arrayPermissionNotGranted = permissionsNotGranted.toArray(arrayPermissionNotGranted);
        FragmentCompat.requestPermissions(this, arrayPermissionNotGranted, KEY_PERMISSION);
    }
}
 
Example 2
Source File: Camera2BasicFragment.java    From opencv-documentscanner-android with Apache License 2.0 5 votes vote down vote up
private void requestCameraPermission() {
    if (FragmentCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
        new ConfirmationDialog().show(getChildFragmentManager(), FRAGMENT_DIALOG);
    } else {
        FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA},
                REQUEST_CAMERA_PERMISSION);
    }
}
 
Example 3
Source File: Camera2BasicFragment.java    From Cam2Caption with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void requestCameraPermission() {
    if (FragmentCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
        new ConfirmationDialog().show(getChildFragmentManager(), FRAGMENT_DIALOG);
    } else {
        FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA},
                REQUEST_CAMERA_PERMISSION);
    }
}
 
Example 4
Source File: CameraFragment.java    From polling-station-app with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void requestCameraPermission() {
    if (FragmentCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
        showInfoDialog(R.string.ocr_camera_permission_explanation);
    } else {
        FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA},
                REQUEST_CAMERA_PERMISSION);
    }
}
 
Example 5
Source File: CameraFragment.java    From polling-station-app with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void requestStoragePermissions() {
    if (FragmentCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
        showInfoDialog(R.string.storage_permission_explanation);
    } else {
        FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE_PERMISSIONS);
    }
}
 
Example 6
Source File: Camera2Fragment.java    From 361Camera with Apache License 2.0 5 votes vote down vote up
/**
 * Requests permissions necessary to use camera and save pictures.
 */
private void requestCameraPermissions() {
    if (shouldShowRationale()) {
        PermissionConfirmationDialog.newInstance().show(getChildFragmentManager(), "dialog");
    } else {
        FragmentCompat.requestPermissions(this, CAMERA_PERMISSIONS, REQUEST_CAMERA_PERMISSIONS);
    }
}
 
Example 7
Source File: CaptureHighSpeedVideoMode.java    From Android-Slow-Motion-Camera2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Requests permissions needed for recording video.
 */
private void requestVideoPermissions() {
    if (shouldShowRequestPermissionRationale(VIDEO_PERMISSIONS)) {
        new ConfirmationDialog().show(getChildFragmentManager(), FRAGMENT_DIALOG);
    } else {
        FragmentCompat.requestPermissions(this, VIDEO_PERMISSIONS, REQUEST_VIDEO_PERMISSIONS);
    }
}
 
Example 8
Source File: Camera2BasicFragment.java    From android-object-distance with Apache License 2.0 5 votes vote down vote up
private void requestCameraPermission() {
    if (FragmentCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
        new ConfirmationDialog().show(getChildFragmentManager(), FRAGMENT_DIALOG);
    } else {
        FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA},
                REQUEST_CAMERA_PERMISSION);
    }
}
 
Example 9
Source File: Camera2Fragment.java    From Camera2-Video with Apache License 2.0 5 votes vote down vote up
protected void requestVideoPermissions() {
    if (CameraUtil.shouldShowRequestPermissionRationale(this, Camera2PermissionDialog.VIDEO_PERMISSIONS)) {
        Camera2PermissionDialog.newInstance(this, mRationaleMessage).show(getChildFragmentManager(), Camera2PermissionDialog.FRAGMENT_DIALOG);
    } else {
        FragmentCompat.requestPermissions(this, Camera2PermissionDialog.VIDEO_PERMISSIONS, Camera2PermissionDialog.REQUEST_VIDEO_PERMISSIONS);
    }
}
 
Example 10
Source File: Camera2Fragment.java    From MultiMediaSample with Apache License 2.0 5 votes vote down vote up
private void requestCameraPermission() {
    if (FragmentCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
        new ConfirmationDialog().show(getChildFragmentManager(), FRAGMENT_DIALOG);
    } else {
        FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA},
                REQUEST_CAMERA_PERMISSION);
    }
}
 
Example 11
Source File: Camera2BasicFragment.java    From Android-Camera2-Front-with-Face-Detection with Apache License 2.0 5 votes vote down vote up
private void requestCameraPermission() {
    if (FragmentCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
        new ConfirmationDialog().show(getChildFragmentManager(), FRAGMENT_DIALOG);
    } else {
        FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA},
                REQUEST_CAMERA_PERMISSION);
    }
}
 
Example 12
Source File: Camera2RawFragment.java    From android-Camera2Raw with Apache License 2.0 5 votes vote down vote up
/**
 * Requests permissions necessary to use camera and save pictures.
 */
private void requestCameraPermissions() {
    if (shouldShowRationale()) {
        PermissionConfirmationDialog.newInstance().show(getChildFragmentManager(), "dialog");
    } else {
        FragmentCompat.requestPermissions(this, CAMERA_PERMISSIONS, REQUEST_CAMERA_PERMISSIONS);
    }
}
 
Example 13
Source File: Camera2VideoFragment.java    From android-Camera2Video with Apache License 2.0 5 votes vote down vote up
/**
 * Requests permissions needed for recording video.
 */
private void requestVideoPermissions() {
    if (shouldShowRequestPermissionRationale(VIDEO_PERMISSIONS)) {
        new ConfirmationDialog().show(getChildFragmentManager(), FRAGMENT_DIALOG);
    } else {
        FragmentCompat.requestPermissions(this, VIDEO_PERMISSIONS, REQUEST_VIDEO_PERMISSIONS);
    }
}
 
Example 14
Source File: PermissionUtils.java    From SimpleSmsRemote with MIT License 2 votes vote down vote up
/**
 * request common permissions via dialog <br/>
 * with common permissions are meant all permissions that can be request via the standard dialog
 *
 * @param fragment    any fragment
 * @param permissions permissions to request
 * @param resultCode  code to identify this request
 */
public static void RequestCommonPermissions(Fragment fragment, String[] permissions, int resultCode) {
    FragmentCompat.requestPermissions(fragment, permissions, resultCode);
}