Issue
Let's say I have 4 activities, A, B, C and D. With a button on each of them, A starts B, B starts C, and C starts D. And let's say on activity B, there is a dynamic listview, populated with the information provided by activity A. When I choose an item from B, it starts C, and when I press the "back" button, I see the activity B with the state I left it (dynamic items and scrolling state).
Now what I want is, with a button on activity D, I want to go back to B, by keeping its state (the items data and scroll position), as if I was on C and pressed back button.
So far what I found is, that for my intent to go back to B from D, I should use "FLAG_ACTIVITY_CLEAR_TOP" as the intent flag.
Any ideas? Thanks.
Solution
You could in Activity C start D by startActivityForResult(Intent intent, int requestCode). When D ends with specified result in activity C in onActivityResult(int requestCode, int resultCode, Intent data) just call finish(); to finish activity C. Remember to set result for activity D, when you want to go back to activity B by
setResult(Activity.RESULT_OK, myIntent); //or any other result or intent
Answered By - Agata
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.