title: "NullPointerException" getActivity().findViewById return null on Fragment in Android
body: <p>I have a problem updating menu items of my Activity from a Fragment after an interstitial banner is closed (using "X" or clicking "back" it's the same).
  Before android HONEYCOMB everything works well also after interstitial banner, maybe because I use android.support.v4.app.Fragment.</p>
  
  <p>in my activity with this layout:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;HorizontalScrollView
          android:id="@+id/menuContainer"
          android:layout_width="match_parent"
          android:layout_height="32dp" /&gt;
  
      &lt;FrameLayout
          android:id="@+id/fragments"
          android:layout_width="match_parent"
          android:layout_height="match_parent" &gt;
      &lt;/FrameLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I add a new fragment and everyting goes fine:</p>
  
  <pre><code>FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
  transaction.replace(R.id.fragments, MyFragment.newInstance());
  transaction.addToBackStack(null);
  transaction.commit();
  </code></pre>
  
  <p>This is Fragment code:</p>
  
  <pre><code>public static MyFragment newInstance() {
      return new MyFragment();
  }
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  }
  
  private View mSimpleContainer;
  private TextView mSimpleText;
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.fragment_test, container, false);
  
      mSimpleContainer = view.findViewById(R.id.mSimpleContainer);
      mSimpleText = (TextView) view.findViewById(R.id.simpleText);
  
      return view;
  }
  
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
  
      mSimpleText.setText("lorem ipsum");
  
      MyActivity act = (MyActivity) getActivity();
  
      if (act != null) {
          HorizontalScrollView menu = (HorizontalScrollView) act.findViewById(R.id.menuContainer);
  
          /**
          * menu is null and I get NullPointerException here after interstitial is closed.
          * Maybe the activity is paused and resumed but I expect that in onActivityCreated the activity is attached
          */
          menu.hideMenuItems();
  
          //This line open an Interstitial banner that when it's closed causes NullPointerException above
          act.showInterstitial(); //If I comment this line everything works fine
      }
  }
  </code></pre>
  
  <p>When it's the correct time to call findViewById in the activity?
  Thanks for any answers</p>