I am developing an application where i need to have a dialog choose for uploading image from gallery or camera. I have found kind of solution here Dialog to pick image from gallery or from camera but the problem is here there is clash in comparing which action is chosen by user.
I would like to know if i can modify in this code and get some result to differentiate either gallery or camera is chosen and then apply action.
Just an advice when you call
startActivityForResult()
to take a photo with camera:Notice that the
startActivityForResult()
method is protected by a condition that callsresolveActivity()
, which returns the first activity component that can handle the intent. Performing this check is important because if you callstartActivityForResult()
using an intent that no app can handle, your app will crash. So as long as the result is not null, it's safe to use the intent.Create new method into Main Activity File called “selectImage()”..for choose option
Now we need return back to our activity with proper Result.
Add this method in onactivity()