Note that there are some explanatory texts on larger screens.

plurals
  1. POVideoView in a fragment is null during orientationchange
    primarykey
    data
    text
    <p>I have a video view in my fragment. When the video is playing and I change the orientation it throws null pointer exception in frgament onPause() where I'm pausing the videview. This problem did not occur previously when the video view was attached to an activity. Recently I had to change the activity to fragment and getting the exception from then.</p> <p>video.xml</p> <pre><code>&lt;FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/fullScreenContainer"&gt; &lt;SurfaceView android:layout_width="0px" android:layout_height="0px" android:id="@+id/dummySurfaceView"/&gt; &lt;/FrameLayout&gt; </code></pre> <p>This is my fragment onPause()</p> <pre><code>@Override public void onPause() { super.onPause(); if (videoView != null) { videoView.pausePlayer(); } } </code></pre> <p><strong>videoView</strong> is an object of the class <strong>Video</strong> that extend RelativeLayout which has <code>VideoView vidPlayer</code> in it</p> <p>Video.java</p> <pre><code>public void pausePlayer() { isPaused = true; vidPlayer.pause(); btnPlay.setImageResource(R.drawable.video_play); controlsManager.cancelHideTimer(); } </code></pre> <p>So, This is the structure -> </p> <pre><code> ___________________________________ | ** MyFragment.java ** | | _______________________________ | | | ** Video.java ** | | | | ___________________________ | | | | | | | | | | | **VideoView vidPlayer** | | | | | |___________________________| | | | | | | | |_______________________________| | | | |___________________________________| </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload