src/android/src/gmvScanner/BarcodeCaptureActivity.java
/**
     * Callback for the result from requesting permissions. This method
     * is invoked for every call on {@link #requestPermissions(String[], int)}.
     * <p>
     * <strong>Note:</strong> It is possible that the permissions request interaction
     * with the user is interrupted. In this case you will receive empty permissions
     * and results arrays which should be treated as a cancellation.
     * </p>
     *
     * @param requestCode  The request code passed in {@link #requestPermissions(String[], int)}.
     * @param permissions  The requested permissions. Never null.
     * @param grantResults The grant results for the corresponding permissions
     *                     which is either {@link PackageManager#PERMISSION_GRANTED}
     *                     or {@link PackageManager#PERMISSION_DENIED}. Never null.
     * @see #requestPermissions(String[], int)
     */
Callback for the result from requesting permissions. This method
is invoked for every call on  #requestPermissions(String[], int).

Note: It is possible that the permissions request interaction
with the user is interrupted. In this case you will receive empty permissions
and results arrays which should be treated as a cancellation.

@param requestCode  The request code passed in  #requestPermissions(String[], int).
@param permissions  The requested permissions. Never null.
@param grantResults The grant results for the corresponding permissions
which is either  PackageManager#PERMISSION_GRANTED
or  PackageManager#PERMISSION_DENIED. Never null.
Callback for the result from requesting permissions . This method is invoked for every call on #requestPermissions ( String [] int ) . Note : It is possible that the permissions request interaction with the user is interrupted . In this case you will receive empty permissions and results arrays which should be treated as a cancellation . @param requestCode The request code passed in #requestPermissions ( String [] int ) . @param permissions The requested permissions . Never null . @param grantResults The grant results for the corresponding permissions which is either PackageManager#PERMISSION_GRANTED or PackageManager#PERMISSION_DENIED . Never null .
@Override
    public void onRequestPermissionsResult(int requestCode,
                                           @NonNull String[] permissions,
                                           @NonNull int[] grantResults) {
        if (requestCode != RC_HANDLE_CAMERA_PERM) {
            Log.d(TAG, "Got unexpected permission result: " + requestCode);
            super.onRequestPermissionsResult(requestCode, permissions, grantResults);
            return;
        }
        if (grantResults.length != 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            Log.d(TAG, "Camera permission granted - initialize the camera source");
            DetectionTypes = getIntent().getIntExtra("DetectionTypes", 0);
            ViewFinderWidth = getIntent().getDoubleExtra("ViewFinderWidth", .5);
            ViewFinderHeight = getIntent().getDoubleExtra("ViewFinderHeight", .7);
            createCameraSource(true, false);
            return;
        }
        Log.e(TAG, "Permission not granted: results len = " + grantResults.length +
                " Result code = " + (grantResults.length > 0 ? grantResults[0] : "(empty)"));
        DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                finish();
            }
        };
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Camera permission required")
                .setMessage(getResources().getIdentifier("no_camera_permission", "string", getPackageName()))
                .setPositiveButton(getResources().getIdentifier("ok", "string", getPackageName()), listener)
                .show();
    }
@ Override public void onRequestPermissionsResult ( int requestCode , @ NonNull String [ ] permissions , @ NonNull int [ ] grantResults ) { if ( requestCode != RC_HANDLE_CAMERA_PERM ) { Log . d ( TAG , "Got unexpected permission result: " + requestCode ) ; super . onRequestPermissionsResult ( requestCode , permissions , grantResults ) ; return ; } if ( grantResults . length != 0 && grantResults [ 0 ] == PackageManager . PERMISSION_GRANTED ) { Log . d ( TAG , "Camera permission granted - initialize the camera source" ) ; DetectionTypes = getIntent ( ) . getIntExtra ( "DetectionTypes" , 0 ) ; ViewFinderWidth = getIntent ( ) . getDoubleExtra ( "ViewFinderWidth" , .5 ) ; ViewFinderHeight = getIntent ( ) . getDoubleExtra ( "ViewFinderHeight" , .7 ) ; createCameraSource ( true , false ) ; return ; } Log . e ( TAG , "Permission not granted: results len = " + grantResults . length + " Result code = " + ( grantResults . length > 0 ? grantResults [ 0 ] : "(empty)" ) ) ; DialogInterface . OnClickListener listener = new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int id ) { finish ( ) ; } } ; AlertDialog . Builder builder = new AlertDialog . Builder ( this ) ; builder . setTitle ( "Camera permission required" ) . setMessage ( getResources ( ) . getIdentifier ( "no_camera_permission" , "string" , getPackageName ( ) ) ) . setPositiveButton ( getResources ( ) . getIdentifier ( "ok" , "string" , getPackageName ( ) ) , listener ) . show ( ) ; }
Callback for the result from requesting permissions.
Callback for the result from requesting permissions .
// we have permission, so create the camerasource