title: ViewPager's fragments seem to bet detached?
body: <p>I have 3 fragments in a viewpager (using compatibility library), the first one is shown when the app loads.
  the 2nd and 3rd pages are a bit CPU intensive, so I would like to load their content only when user swipes to them first.</p>
  
  <p>for this I have implemented ViewPager.OnPageChangeListener and overrode onPageSelected to call an onResume in the Fragment</p>
  
  <pre><code>public void onPageSelected(int position) {
      getItem(viewPager.getCurrentItem()).onResume();
  }
  </code></pre>
  
  <p>in the Fragments onResume is the following:</p>
  
  <pre><code>@Override
  public void onResume() {
      super.onResume();
  
      if ((MainActivity) getActivity() != null &amp;&amp; ((MainActivity) getActivity()).pager != null &amp;&amp; ((MainActivity) getActivity()).pager.getCurrentItem() == 1) {
          doCpuIntensiveLoading();
      }
  }
  </code></pre>
  
  <p>to prevent it from loading when instantiated and not visible, but to load when pager's getCurrentItem() returns the fragment's id.</p>
  
  <p>but! when I scroll to the page getActivity() returns null although the fragment's menu is populated and calling load from menu is working.</p>
  
  <p>please let me know if you need more details.</p>