title: NullPointerException when calling super.onCreateView() in MiniControllerFragment
body: <p>In my app I'm trying <a href="https://codelabs.developers.google.com/codelabs/cast-videos-android/#6" rel="nofollow noreferrer">to implement a MiniControlFragment</a> which is shown when the user decides to close <code>ExpandedControlsActivity</code> (a full-screen version of Mini controller). Instead of adding it declaratively to the xml layout I need to do that programmatically.</p>
  
  <p>So I created own class which extends <code>MiniControllerFragment</code>:</p>
  
  <pre><code>public class CastControllingFragment extends MiniControllerFragment
  {
      @Override
      public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle)
      {
          View view = super.onCreateView(layoutInflater, viewGroup, bundle);
          if (view != null) {
              FrameLayout.LayoutParams frameLayoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
              view.setLayoutParams(frameLayoutParams);
          }
          return view;
      }
  
      public static void show(FragmentActivity activity) {
          FragmentManager fragmentManager = activity.getSupportFragmentManager();
          if (fragmentManager.findFragmentById(R.id.castMiniController) == null)
          {
              View rootView = activity.findViewById(R.id.fragment_container);
              if (rootView instanceof ViewGroup)
              {                    
                 fragmentManager.beginTransaction().add(R.id.fragment_container, new CastControllingFragment()).commit();
              }
          }
      }
  
  }
  </code></pre>
  
  <p>I instantiate it and add it to the fragment transaction in <code>Activity</code>'s <code>onResume</code> callback:</p>
  
  <pre><code>    @Override
      protected void onResume() {
          CastControllingFragment.show(this);
          super.onResume();
      }
  </code></pre>
  
  <p>This is the <code>Activity</code>'s layout with <code>FrameLayout</code> as container for my fragment:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:app="http://schemas.android.com/apk/res-auto"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"&gt;
      &lt;FrameLayout
          android:id="@+id/fragment_container"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
      &lt;/FrameLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>But, when the <code>super.onCreateView()</code> in my <code>CastControllingFragment</code> is called then I get the following error:</p>
  
  <blockquote>
    <p>java.lang.RuntimeException: Unable to resume activity
    java.lang.NullPointerException: Attempt to read from null array
                                                                                          at
    android.app.ActivityThread.performResumeActivity(ActivityThread.java:3400)
                                                                                          at
    android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3440)
                                                                                          at
    android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2713)
                                                                                          at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                                          at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                          at android.os.Looper.loop(Looper.java:154)
                                                                                          at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                                          at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)</p>
    
    <p>Caused by: java.lang.NullPointerException: Attempt to read from null
    array
                                                                                          at
    com.google.android.gms.cast.framework.media.widget.MiniControllerFragment.zza(Unknown
    Source)
                                                                                          at
    com.google.android.gms.cast.framework.media.widget.MiniControllerFragment.onCreateView(Unknown
    Source)
                                                                                          at
    com.google.sample.cast.refplayer.CastControllingFragment.onCreateView(CastControllingFragment.java:22)
                                                                                          at
    android.support.v4.app.Fragment.performCreateView(Fragment.java:2087)
                                                                                          at
    android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1113)
                                                                                          at
    android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1295)
                                                                                          at
    android.support.v4.app.BackStackRecord.run(BackStackRecord.java:801)
                                                                                          at
    android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1682)
                                                                                          at
    android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
                                                                                          at
    android.support.v4.app.FragmentActivity.onPostResume(FragmentActivity.java:499)
                                                                                          at
    android.support.v7.app.AppCompatActivity.onPostResume(AppCompatActivity.java:175)
                                                                                          at android.app.Activity.performResume(Activity.java:6792)
                                                                                          at
    android.app.ActivityThread.performResumeActivity(ActivityThread.java:3377)
                                                                                          at
    android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3440) 
                                                                                          at
    android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2713) 
                                                                                          at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                                                                                          at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) 
                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                          at android.os.Looper.loop(Looper.java:154) 
                                                                                          at android.app.ActivityThread.main(ActivityThread.java:6077) 
                                                                                          at java.lang.reflect.Method.invoke(Native Method) 
                                                                                          at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
                                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)</p>
  </blockquote>