Earlier this year, I was working on a freelance project that required me to do the following
- Allow the user to open up one of the Image viewing apps when they click a button
- Allow the user to select one image
- Once the user selects an image, take that image, and display the image on an Activity layout
- If the user is happy with the image, allow the user to upload that photo.
Sounds simple right? You just fire up an intent, and then you override the onActivityResult method upon user’s selection of the image, and then you load up the image onto your layout using your favorite Image loading library (I use Picasso). The code for the onActivityResult looks something like this.
This part is pretty straightforward. The insanity starts when you want to take the resulting image file and then upload it to your cloud storage like AWS S3. A sane developer might think that a method like this would exist on the profilePhotoUri
But it doesn’t. Instead, you have to instantiate a cursor and perform some type of surgery on your resulting photoUri that you get back on your onActivityResult.
This was my face after learning about this ????????