app/src/main/java/com/example/iamatourist/MainActivity.java
@Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        switch (requestCode) {
            case CAMERA_REQUEST_CODE: {
                if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    if (hasCamera) {
                        fab.setEnabled(true);
                        canCamera = true;
                    }
                } else {
                    fab.setEnabled(false);
                    canCamera = false;
                }
                return;
            }
            case READ_REQUEST_CODE: {
                if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    canRFiles = true;
                } else {
                    canRFiles = false;
                }
            }

            case WRITE_REQUEST_CODE: {
                if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    canWFiles = true;
                } else {
                    canWFiles = false;
                }
            }
            case LOCATION_REQUEST_CODE: {
                if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    canLocation = true;
                } else {
                    canLocation = false;
                }
            }
        }
    }
/**
     * This enables the fab if the app has got permission from the user to use the camera
     *
     * @param requestCode  the code, in this case 0
     * @param permissions  the type of permission that it is asking for
     * @param grantResults the results of the permission checks
     */
This enables the fab if the app has got permission from the user to use the camera
@param requestCode  the code, in this case 0
@param permissions  the type of permission that it is asking for
@param grantResults the results of the permission checks
This enables the fab if the app has got permission from the user to use the camera @param requestCode the code in this case 0 @param permissions the type of permission that it is asking for @param grantResults the results of the permission checks
@Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        switch (requestCode) {
            case CAMERA_REQUEST_CODE: {
                if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    if (hasCamera) {
                        fab.setEnabled(true);
                        canCamera = true;
                    }
                } else {
                    fab.setEnabled(false);
                    canCamera = false;
                }
                return;
            }
            case READ_REQUEST_CODE: {
                if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    canRFiles = true;
                } else {
                    canRFiles = false;
                }
            }
            case WRITE_REQUEST_CODE: {
                if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    canWFiles = true;
                } else {
                    canWFiles = false;
                }
            }
            case LOCATION_REQUEST_CODE: {
                if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    canLocation = true;
                } else {
                    canLocation = false;
                }
            }
        }
    }
@ Override public void onRequestPermissionsResult ( int requestCode , String [ ] permissions , int [ ] grantResults ) { switch ( requestCode ) { case CAMERA_REQUEST_CODE : { if ( grantResults . length > 0 && grantResults [ 0 ] == PackageManager . PERMISSION_GRANTED ) { if ( hasCamera ) { fab . setEnabled ( true ) ; canCamera = true ; } } else { fab . setEnabled ( false ) ; canCamera = false ; } return ; } case READ_REQUEST_CODE : { if ( grantResults . length > 0 && grantResults [ 0 ] == PackageManager . PERMISSION_GRANTED ) { canRFiles = true ; } else { canRFiles = false ; } } case WRITE_REQUEST_CODE : { if ( grantResults . length > 0 && grantResults [ 0 ] == PackageManager . PERMISSION_GRANTED ) { canWFiles = true ; } else { canWFiles = false ; } } case LOCATION_REQUEST_CODE : { if ( grantResults . length > 0 && grantResults [ 0 ] == PackageManager . PERMISSION_GRANTED ) { canLocation = true ; } else { canLocation = false ; } } } }
This enables the fab if the app has got permission from the user to use the camera
 @param requestCode  the code, in this case 0
 @param permissions  the type of permission that it is asking for
 @param grantResults the results of the permission checks
This enables the fab if the app has got permission from the user to use the camera @param requestCode the code in this case 0 @param permissions the type of permission that it is asking for @param grantResults the results of the permission checks