I have a ListView that is dynamic and will constantly change. The user selects an item and goes to a different activity.
What I want: When they hit back button and return to the ListView, I would like to call a certain action to refresh ListView (in my case an AsyncTask).
I have figured out one way to do this: By adding my refreshing code in onResume. But I find it refreshes a little too much — I only want it to refresh when coming from the forward activities.
put your “refresh” code inside of
onStart()instead ofonResume().onStart()gets “Called when the activity is becoming visible to the user.” – Activity LifecycleWhich means that it will happen only at the time that you activity gets put onto the screen.