How to refresh fragments 'onResume?'

Viewed 23691

I want to refresh fragments from an Actvitiy. (Let's call the activity A) Activity A contains the fragments.

When I finish Activity B then Activity A should refresh the fragments.

I was thinking this would be done in onResume? I tried simply restarting the activity through an intent but that's not usability friendly.

So how do I refresh fragments when I resume an activity?

3 Answers

The onResume() get called always before the fragment is displayed. Even when the fragment is created for the first time . So you can simply move your from onViewCreated() to onResume.

@Override
public void onResume() {
super.onResume();

//move your code from onViewCreated() here 

}
Related