Priya Sasane
Priya Sasane

Reputation: 103

How to call onResume() of Fragment

I used Navigation drawer , with number of fragments. I want to call onResume() of fragment , Where i need to load updated data from server.

Upvotes: 5

Views: 18512

Answers (2)

Simptive
Simptive

Reputation: 987

You can still achieve whatever you want to with onResume() in a fragment using onHiddenChanged(). Below is a sample method:

@Override
public void onHiddenChanged(boolean hidden) {
    super.onHiddenChanged(hidden);
    if(hidden)
        //Windup;
    else
        //initialize;
}

Upvotes: 0

Skizo-ozᴉʞS ツ
Skizo-ozᴉʞS ツ

Reputation: 20636

onResume() will be called when your Activity onResume() is called, you don't have to call onResume() in a Fragment.

Read this to understand the Fragment Lifecycle

If you want to do it from your Fragment you should do something like this

@Override
    public void onResume(){
        super.onResume();
        //OnResume Fragment
    }

Also if you have to do something general you can do it on your Activity it's the same as the Fragment

Upvotes: 13

Related Questions