How to maintain tab state in android
<p>I've two tabs with two different contents.</p>

<ul>
<li>Tab1->video streaming</li>
<li>Tab2->listview.</li>
</ul>

<p>While click an <code>listview</code> item, I'll go to details page <code>activity</code>. When back is pressed, it will move back to <code>listview</code> well. But in background, the video (Tab1 content) is playing. How to stop this?</p>

<p>My code:</p>

<p>...</p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
        // sets the Bundle
        super.onCreate(savedInstanceState);
        // sets the context
        setContentView(R.layout.videostream);
        myVideoView = (VideoView) findViewById(R.id.vview);
        mProgress = new ProgressDialog(this);


        PlayVideo();

    }

    private void PlayVideo() {
        try {

            mProgress = ProgressDialog.show(VideoActivity.this, "",
                    "Buffering video...", true);
            mProgress.setCancelable(true);


            myVideoView.setVideoURI(Uri.parse(vSource));
            myVideoView.setMediaController(new MediaController(this));
            myVideoView.requestFocus();
            myVideoView.setOnPreparedListener(new OnPreparedListener() {

                public void onPrepared(MediaPlayer mp) {
                    mProgress.dismiss();
                    myVideoView.start();
                }
            });

         } catch (Exception e) {

            mProgress.dismiss();
            System.out.println("Video Play Error :" + e.toString());
            finish();

        }

    }

    public void onSaveInstanceState(Bundle outState) {

        mStartTime = myVideoView.getCurrentPosition();
        outState.putInt("restartTime", mStartTime);
        super.onSaveInstanceState(outState);
    }

    @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        myInt = savedInstanceState.getInt("restartTime");
        myVideoView.seekTo(myInt);

        myVideoView.start();

    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {

        super.onConfigurationChanged(newConfig);

       // 2 means landscape and 1 means portait mode
       if (newConfig.orientation == 2) {
           mProgress.dismiss();

       }

    }
    @Override
    public void onPause() {
        super.onPause();

        myVideoView.stopPlayback();

    }
    @Override
      public void onResume() {
            super.onResume();

            PlayVideo();
        }
</code></pre>
