In my main activity, when you click a button, it launches a new activity (act2), in which another activity (act3) is loaded onCreate (assuming it was launched by that specific button only)
act3 is a listview, selecting an item returns you to act2 and sets a textview accordingly. If you press the back button in act3 it takes you to act2. However, if act3 originated from that specific button and no item is selected I would like for it to take you back to the main activity instead. What is the best way to handle this?
Set the activity result of act3 to
RESULT_OKif something was selected before finishing. inonActivityResultin act2, if the result wasRESULT_CANCELLED,finish(). If it wasRESULT_OK, process the returned value.