OnResume() not called in Fragment using tabLayout and ViewPager
<p>i'm developing an app using <code>tabLayout</code>.</p>

<p>I've a problem: When I try to reactivate a <code>Fragment</code>, the method <code>OnResume</code> is non called. </p>

<p>This is my activity:</p>

<pre><code> private void init() {
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Nuovo Ticket", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });


    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

    final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    final PagerAdapter adapter = new PagerAdapter
            (getSupportFragmentManager(), tabLayout.getTabCount());
    viewPager.setAdapter(adapter);

    tabLayout.setupWithViewPager(viewPager);
}
</code></pre>

<p>I use a FragmentStatePagerAdapter like this:</p>

<pre><code>public class PagerAdapter extends FragmentStatePagerAdapter {
int mNumOfTabs;

public PagerAdapter(FragmentManager fm, int NumOfTabs) {
    super(fm);
    this.mNumOfTabs = NumOfTabs;
}

@Override
public Fragment getItem(int position) {

    switch (position) {
        case 0:
            return new LavorazioneFragment();
        case 1:
            return new PendingFragment();
        case 2:
            return new StoriciFragment();
        default:
            return null;
    }
}

@Override
public int getCount() {
    return mNumOfTabs;
}
</code></pre>

<p>}</p>

<p>When i reactivate the <code>TAB1</code> Fragment from <code>TAB3</code> Fragment (the last one), the <code>OnResume</code> Method is called. But, for example, </p>

<p>When I try to reactivate the first tab from the second, never called.</p>