Class CameraPermissionManager

java.lang.Object
com.microblink.blinkid.util.CameraPermissionManager

public class CameraPermissionManager extends 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

    Modifier and Type
    Method
    Description
    void
    Asks the user to give camera permission and displays the layout returned by getAskPermissionOverlay if user denies the permission.
    android.view.View
    Returns the layout that should be displayed when camera permission is not given.
    boolean
    Returns true if camera permission is available.
    void
    onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
    This method handles request permission results as given to onRequestPermissionResult callback of Activity.
    void
     

    Methods inherited from class java.lang.Object

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

    • 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 Details

    • 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 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()