title: void android.view.View.dispatchWindowVisibilityChanged(int)' on a null object reference
body: <p>I have an Activity A [MainActivity] from which I start Activity B [Videoplayer]<br />
  <strong>Case 1:</strong> Click a video thumbnail from Activity A =&gt; Goes to Activity B =&gt; Play video for few seconds (important: you need to play the video for few seconds) =&gt; Click Back navigation =&gt; comes back to Activity A =&gt; <strong>No crash</strong>.</p>
  <p><strong>Case 2:</strong> Click a video thumbnail from Activity A =&gt; Goes to Activity B =&gt; Buffers and video starts to play =&gt; immediately Click Back navigation (important: do not play the video) =&gt; app tries to come back to Activity A =&gt; <strong>Crashes and its consistent</strong>.</p>
  <p><strong>Note:</strong> I have no code written in onResume() of Activity A, just to ensure that I haven't overridden any onResume() related code, which might lead to crash.
  The stacktrace does not point to a line in app code, it just shows a stacktrace from android source lib. I have spent more than <strong>4+hrs</strong> on this, any help is appreciated.</p>
  <p><strong>Activity B [Player Activity] code:</strong></p>
  <pre><code>public class VitamioPlayerActivity extends AppCompatActivity implements MediaPlayer.OnErrorListener, MediaPlayer.OnPreparedListener, MediaPlayer.OnTimedTextListener {
  public static final String TAG = VitamioPlayerActivity.class.getSimpleName();
  
  @Bind(R.id.videoView)
  VideoView videoView;
  
  @Bind(R.id.progressBar)
  ProgressBar progressBar;
  
  @Bind(R.id.subtitle_view)
  TextView mSubtitleView;
  
  private VideoModel videoModel;
  private long mPosition = 0;
  
  private boolean isLiveChannel;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_vitamio);
      ButterKnife.bind(this);
      StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
      StrictMode.setThreadPolicy(policy);
  
      if (getIntent() == null)
          return;
  
      if (getIntent().getExtras() == null)
          return;
  
      if (!getIntent().getExtras().containsKey(AppConstant.KEY_BUNDLE_VIDEO))
          return;
  
      videoModel = (VideoModel) getIntent().getExtras().getSerializable(AppConstant.KEY_BUNDLE_VIDEO);
      if (videoModel == null)
          return;
  
      playVideo();
  }
  
  
  VideoControllerView controllerView;
  
  void playVideo() {
      String path = null;
      if (videoModel.isLoadBalancer()) {
          path = URLHelper.getInstance().getPlayableVideoUrl(videoModel.getVideoUrl());
      } else
          path = videoModel.getVideoUrl();
  
      if (TextUtils.isEmpty(path)) {
          Toast.makeText(this, &quot;Please edit MediaPlayer Activity, &quot; + &quot;and set the path variable to your media file path.&quot; + &quot; Your media file must be stored on sdcard.&quot;, Toast.LENGTH_LONG).show();
          return;
      }
      isLiveChannel = !(path.contains(&quot;.mp4&quot;));
      videoView.setVideoURI(Uri.parse(path));
      videoView.setMediaController(controllerView = new VideoControllerView(this, !isLiveChannel));
      videoView.requestFocus();
      videoView.start();
  
      videoView.setOnPreparedListener(this);
      videoView.setOnErrorListener(this);
  }
  
  @Override
  public void onPrepared(MediaPlayer mediaPlayer) {
      mediaPlayer.setPlaybackSpeed(1.0f);
  }
  
  @Override
  public void onTimedText(String text) {
      mSubtitleView.setText(text);
  }
  
  @Override
  public void onTimedTextUpdate(byte[] pixels, int width, int height) {
      int a = 1;
  }
  
  
  @Nullable
  @OnClick(R.id.imvHeaderBack)
  void doBack() {
      finish();
  }
  
  @Override
  public void onBackPressed() {
      finish();
  }
  
  @Override
  protected void onPause() {
      mPosition = videoView.getCurrentPosition();
      videoView.stopPlayback();
      super.onPause();
  }
  
  @Override
  protected void onResume() {
      if (mPosition &gt; 0) {
          videoView.seekTo((int) mPosition);
          mPosition = 0;
      }
      super.onResume();
  }
  
  @Override
  public boolean onError(MediaPlayer mp, int what, int extra) {
      WindowUtils.getInstance().genericInfoMsgWithOKCallBack(this, null, &quot;Sorry, Cannot Play Video&quot;, R.color.redStatus,
              new ViewConstructor.InfoDisplayListener() {
                  @Override
                  public void onPositiveSelection(DialogInterface alertDialog) {
                      doBack();
                  }
              });
      return true;
  }
  </code></pre>
  <p>}</p>
  <p><strong>Stacktrace:</strong></p>
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.dispatchWindowVisibilityChanged(int)' on a null object reference
      at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1310)
      at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1310)
      at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1310)
      at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1310)
      at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1310)
      at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1310)
      at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1310)
      at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1310)
      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1410)
      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1134)
      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6050)
      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:860)
      at android.view.Choreographer.doCallbacks(Choreographer.java:672)
      at android.view.Choreographer.doFrame(Choreographer.java:608)
      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:846)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:5442)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
  </code></pre>