Android,切换到另一个选项卡后,选项卡的意图不会停止 [英] Android, Intent of a tab does not stop after switching to another tab

查看:123
本文介绍了Android,切换到另一个选项卡后,选项卡的意图不会停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个标签显示两个不同的电视频道,但当我在标签之间切换时,他们的活动(意图)继续运行,然后他们混淆了。如何确保一个频道在新节目开始前停止播放?



以下是活动类的代码:



I am having two tabs to show two different TV channels, but when I switch between tabs, their activity(intent) keep running, and they mix up. how can I make sure one channel stops playing before the new one starts?

Here is the code for Activity class:

public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.videoview);
    extras = getIntent().getExtras();
    progressDialog = ProgressDialog.show(TvMenuOne.this, "TV1",
            "Please Wait..", true, true);
    PlayVideo();
}

private void PlayVideo() {
    try {
        videoView = (VideoView) findViewById(R.id.surface_view);
        if(extras.getString("id").equals("one")){
            videoView.setVideoPath(pathL);
        }
        if(extras.getString("id").equals("two")){
            videoView.setVideoPath(pathM);
        }

        videoView.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
        videoView.setMediaController(new MediaController(TvMenuOne.this));

        videoView.setOnPreparedListener(new OnPreparedListener() {

            public void onPrepared(MediaPlayer mp) {
                progressDialog.dismiss();
                videoView.start();
            }
        });

    } catch (Exception e) {
        progressDialog.dismiss();
        System.out.println("Video Play Error :" + e.toString());
        finish();
    }
}

推荐答案

在playvideo之后()

after playvideo()
progressDialog .Dismiss();


这篇关于Android,切换到另一个选项卡后,选项卡的意图不会停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆