Write an app to select an image from the phone's gallery, and let the user
decide if they like it.
Your first activity ...
In the gallery ...
- If the user uses the phone's back button to leave the gallery no
URI is returned.
- If a photo is selected the URI is returned.
Back in your first activity ...
- If no URI is returned then popup a Toast saying the user is a wimp,
and finish.
- If a URI is returned it is sent to a second activity. You have to use
getApplicationContext() instead of this when you create
the Intent (because it's in the ActivityResultLauncher
object, not just in the Activity object).
In your second activity ...
- Use getParcelableExtra to extract the Uri
- Display the photo (ala UseSystemActivity.java).
- Have two buttons, one for "like" and one for "dislike".
- Return a flag indicating which button the user pressed.
And back in your first activity ...
- If the flag is "dislike", or the user has pushed the back button, then
loop back to the gallery to select another image for the user to evaluate.
- If the flag is "like" then popup a Toast saying that the user likes
it and finish.
Use best practices for all aspects of the code!
Answer