Android-Image-Cropper icon indicating copy to clipboard operation
Android-Image-Cropper copied to clipboard

After Taking Picture on Nexus 5x (Android 6.0.1) does not work properly

Open TheCorpAdmin opened this issue 10 years ago • 3 comments

Dear Arthur, first of all i thank you for developing such a nice library. Recently, i have changed my cell phone to new Nexus 5x and faced the problem that capturing the picture with native google camera2 app does not load image after capture. I would really appreciate if you care about this issue.

thnx

TheCorpAdmin avatar Jan 29 '16 05:01 TheCorpAdmin

@TheCorpAdmin Based on the Sample from @ArthurHub, this fix works on Nexus 5 | Android 6.0.1

Add permisson to the AndroidManifest.xml and replace the getPickImageResultUri method.

<uses-permission android:name="android.permission.CAMERA"/>

 /**
     * Get the URI of the selected image from {@link #getPickImageChooserIntent()}.<br/>
     * Will return the correct URI for camera and gallery image.
     *
     * @param data the returned data of the activity result
     */
    public Uri getPickImageResultUri(Intent data) {
        boolean isCamera = true;
        if (android.os.Build.VERSION.SDK_INT >= 23) {
            isCamera = (data != null && data.getClipData() != null) ? false : true;
        } else {
            if (data != null) {
                String action = data.getAction();
                isCamera = action != null && action.equals(MediaStore.ACTION_IMAGE_CAPTURE);
            }
        }
        return isCamera ? getCaptureImageOutputUri() : data.getData();
    }

m1d1 avatar Jan 30 '16 00:01 m1d1

Awesome, I will update the code snippets. Thank you.

ArthurHub avatar Jan 30 '16 08:01 ArthurHub

Well... I hate this stuff :angry: Updated my Moto X to 6.0 but I don't have this issue with my default camera, emulator also works fine#$%@#$ Changed the code to the one suggested by @m1d1 but then image from Dropbox stopped working because data.getClipData() is null in its case... So... as far as I know adding data.getData() != null should be enough, please let me know if it doesn't works for Nexus.

public Uri getPickImageResultUri(Intent data) {
    boolean isCamera = true;
    if (data != null && data.getData() != null) {
        String action = data.getAction();
        isCamera = action != null && action.equals(MediaStore.ACTION_IMAGE_CAPTURE);
    }
    return isCamera ? getCaptureImageOutputUri() : data.getData();
}

ArthurHub avatar Feb 20 '16 15:02 ArthurHub