title: How to refresh SurfaceView when Activity onResume?
body: <p>I play a rtsp video stream using <code>MediaPlayer</code> and display it in a <code>SurfaceView</code>. I do MediaPlayer initial works in <code>Activity.onResume()</code> and release it in <code>Activity.onPause()</code>. It works fine when jump to a <strong>normal</strong> Activity(called <code>onPause</code>) then return back(called <code>onResume</code>). </p>
  
  <p>The problem is, while video is playing, jump to a <strong>dialog-like</strong> Activity and return back, the video cannot be refreshed(video frame is frozen) but audio was fine. What can I do to play video stream normally in this situation? How to refresh the SurfaceView?</p>
  
  <p>Thank you all.</p>
  
  <p>ps: As description above, <strong>normal Activity</strong> is an Activity that fill up the whole window, and <strong>dialog-like Activity</strong> is an Activity that looks like a AlertDialog, usually an Activity with <code>android:theme="@android:style/Theme.Dialog"</code> theme, just like GoogleVoice app. When this kind of Activity is foreground, we can see part of the background Activity.</p>
  
  <p><strong>EDIT</strong>: My code is a little bit complex, and I paste the key snippet:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      //....
      mPreview = (SurfaceView) this.findViewById(R.id.playerView);
      mHolder = mPreview.getHolder();
      mHolder.addCallback(this);
      mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  }
  
  @Override
  protected void onResume() {
      mPath = "rtsp://10.10.20.42/Viral.mp4";
      // Create a new media player and set the listeners
      mMediaPlayer = new MediaPlayer();
      mMediaPlayer.setDataSource(mPath);
      // mMediaPlayer.setDisplay(holder);
      mMediaPlayer.setScreenOnWhilePlaying(true);
      mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
      mMediaPlayer.prepareAsync();
      mMediaPlayer.setOnBufferingUpdateListener(this);
      mMediaPlayer.setOnCompletionListener(this);
      mMediaPlayer.setOnPreparedListener(this);
      mMediaPlayer.setOnVideoSizeChangedListener(this);
      mMediaPlayer.setOnErrorListener(this);
  
      super.onResume();
  }
  
  @Override
  protected void onPause() {
      if (mMediaPlayer != null) {
  
          mMediaPlayer.release();
          mMediaPlayer = null;
      }
      super.onPause();
  }
  </code></pre>