Skip to content Skip to sidebar Skip to footer

App Crashing Because Uri Give Nullpointerexception

am developing an app to upload images to my server via gallery and camera My problem is I get a NullPointerException on some of my code and I have NO idea of how to fix this. the e

Solution 1:

Delete all the Cursor stuff. There is not supposed to be a Uri returned by ACTION_IMAGE_CAPTURE. And, even if there were a Uri, there is no requirement for the MediaStore to know about it, and the DATA column is no longer available on Android Q and higher.

Your image will be the thumbnail Bitmap from data.getExtras().get("data");.

Alternatively, provide your own Uri in EXTRA_OUTPUT (instead of the null that you are providing now), so you control where the image should be stored. This sample app shows how to use FileProvider with EXTRA_OUTPUT for this purpose.

Post a Comment for "App Crashing Because Uri Give Nullpointerexception"