I need my fragments to always call a certain function when they are the active fragment, so I put it in onResume(), but it isn't being called.
Fragment A
@Override
public void onResume(){
super.onResume();
Log.d("clear state", " "+clear);
if(clear == true)
{
restart();
clear = false;
calculate();
}
}
I use a FragmentPagerAdapter with a ViewPager to switch fragments
public class ScoutingFragSingle extends FragmentPagerAdapter{
@Override
public Fragment getItem(int index) {
Bundle data = new Bundle();
switch(index){
case 0:
TeamsFragment teamsFragment = new TeamsFragment();
data.putInt("current_page", index+1);
teamsFragment.setArguments(data);
return teamsFragment;
case 1:
data.putInt("current_page", index+1);
data.putInt("matchId", matchNum);
aFragment.setArguments(data);
return aFragment;
So how would I make the fragments call their onResume()?