Reputation: 4269
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?
Upvotes: 0
Views: 414
Reputation: 38075
Set the activity result of act3 to RESULT_OK
if something was selected before finishing. in onActivityResult
in act2, if the result was RESULT_CANCELLED
, finish()
. If it was RESULT_OK
, process the returned value.
Upvotes: 1