os-fileup icon indicating copy to clipboard operation
os-fileup copied to clipboard

App crashes when I take picture from camera

Open MuhammadFaizan980 opened this issue 6 years ago • 6 comments

When I select image from gallery, it works fine but when I select camera option, after taking picture and pressing ok, app crashes, I traced the issue to intent being null. App works fine on emulator but not on real devices.

MuhammadFaizan980 avatar Aug 21 '19 05:08 MuhammadFaizan980

can you help me with configs of your device?

mgks avatar Aug 21 '19 05:08 mgks

Samsung s6 h+, android version 7.1 Huawei y9 prime, android 9.0

MuhammadFaizan980 avatar Aug 21 '19 06:08 MuhammadFaizan980

I have the exact same problem on my Samsung Galaxy S7 android 8.0 and OnePlus One android 6.0.1. My app is targeting sdk version 28. Anybody had any luck with solving this, or at least have an idea what could be the cause?

urospodkriznik avatar Sep 18 '19 06:09 urospodkriznik

This stackoverflow answer gave me idea of what is wrong here: https://stackoverflow.com/questions/6982184/camera-activity-returning-null-android#answer-10230234

If you pass the extra parameter MediaStore.EXTRA_OUTPUT with the camera intent then camera activity will write the captured image to that path and it will not return the bitmap in the onActivityResult method.

So intent in onActivityResult should always be null since MediaStore.EXTRA_OUTPUT parameter is used in this code. In line 81 NullPointerException is thrown when calling intent.getClipData(). But it is ok because null == intent.getClipData() && null == intent.getDataString() is not necessary here. Though, problem might occure if variable cam_file_data is null too.

urospodkriznik avatar Sep 18 '19 10:09 urospodkriznik

@MuhammadFaizan980 @urospodkriznik hello, can you guys test out the latest repo update? and do let us know your results.

mgks avatar Sep 24 '19 14:09 mgks

@mgks hello again, I tested your latest repo update and in works nice now. Thank you!

urospodkriznik avatar Sep 25 '19 14:09 urospodkriznik