Issue
I have an activity that loads and displays data fetched from a web service.
While the activity is fetching data, it will show a progress dialog.
Now, on this activity, there is a button that will open a new activity, to edit the data. What I want is, after I edit the data, the EditActivity finish(), and the screen will display an updated data (after fetching the data again).
So, I put the fetchData() method in onPostResume() of the first activity. The problem is, everytime the progress dialog is dismissed, it triggers onPostResume() as well. So, I am stuck in a loop.
Any suggestions?
EDIT: Okay, so using onActivityResult() fixes that!
New problem though, what if the views that I want to update is in a fragment? I tried using onActivityResult, but it does nothing!
Solution
User startActivityForResult to start the EditActivity and use setResult the return the data.
Update the display in onActivityResult
method which is triggered when the onResume is called in the Starting Activity. Make sure to check resultCode == RESULT_OK.
Answered By - Eric Liu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.