Class CameraPermissionManager


  • public class CameraPermissionManager
    extends java.lang.Object
    Helper class that shows the camera permission screen when user has denied camera permission on Android 6.0+.
    • Constructor Summary

      Constructors 
      Constructor Description
      CameraPermissionManager​(android.app.Activity activity)
      Creates new camera permission manager and attaches it to activity.
      CameraPermissionManager​(android.app.Fragment fragment)
      Creates new camera permission manager and attaches it to fragment.
      CameraPermissionManager​(androidx.fragment.app.Fragment fragment)
      Creates new camera permission manager and attaches it to fragment.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void askForCameraPermission()
      Asks the user to give camera permission and displays the layout returned by getAskPermissionOverlay if user denies the permission.
      android.view.View getAskPermissionOverlay()
      Returns the layout that should be displayed when camera permission is not given.
      boolean hasCameraPermission()
      Returns true if camera permission is available.
      void onRequestPermissionsResult​(int requestCode, java.lang.String[] permissions, int[] grantResults)
      This method handles request permission results as given to onRequestPermissionResult callback of Activity.
      void onResume()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CameraPermissionManager

        @UiThread
        public CameraPermissionManager​(@NonNull
                                       android.app.Activity activity)
        Creates new camera permission manager and attaches it to activity.
        Parameters:
        activity - The activity that contains camera view.
      • CameraPermissionManager

        @UiThread
        public CameraPermissionManager​(@NonNull
                                       android.app.Fragment fragment)
        Creates new camera permission manager and attaches it to fragment.
        Parameters:
        fragment - The fragment that contains camera view.
      • CameraPermissionManager

        @UiThread
        public CameraPermissionManager​(@NonNull
                                       androidx.fragment.app.Fragment fragment)
        Creates new camera permission manager and attaches it to fragment.
        Parameters:
        fragment - The fragment that contains camera view.
    • Method Detail

      • getAskPermissionOverlay

        @Nullable
        @UiThread
        public android.view.View getAskPermissionOverlay()
        Returns the layout that should be displayed when camera permission is not given. You should put this view somewhere in your view hierarchy. The view is initially invisible and will become visible only after calling askForCameraPermission and permission was not given. You can override this layout by providing custom res/layout/mb_camera_permission_overlay.xmlxml.
        Returns:
        View layout that is under control of CameraPermissionManager.
      • hasCameraPermission

        @AnyThread
        public boolean hasCameraPermission()
        Returns true if camera permission is available. You should call resume() on RecognizerView only if this method returns true.
        Returns:
        whether or not camera permission is available
      • askForCameraPermission

        @MainThread
        public void askForCameraPermission()
        Asks the user to give camera permission and displays the layout returned by getAskPermissionOverlay if user denies the permission.
      • onRequestPermissionsResult

        @MainThread
        public void onRequestPermissionsResult​(int requestCode,
                                               @NonNull
                                               java.lang.String[] permissions,
                                               @NonNull
                                               int[] grantResults)
        This method handles request permission results as given to onRequestPermissionResult callback of Activity.
        Parameters:
        requestCode - The request code as given to callback method.
        permissions - The permissions array.
        grantResults - The grant results as given to callback method.
      • onResume

        public void onResume()