0

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!

Jackyef
  • 4,734
  • 18
  • 26
  • 1
    Start the `EditActivity` with `startActivityForResult()`, and call `fetchData()` in `onActivityResult()`. – Mike M. Nov 19 '15 at 10:39
  • where is you code can you show it. so its easy to help you. and u have use `onResume()` for this – Jaydip Nov 19 '15 at 10:39
  • Please try searching the site: http://stackoverflow.com/questions/6147884/onactivityresult-not-being-called-in-fragment Also, one post, one question. Don't change what you're asking halfway through, especially after the original question has been answered. – Mike M. Nov 19 '15 at 13:24

1 Answers1

0

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.

Eric Liu
  • 1,516
  • 13
  • 19