我正在尝试实现一个onCompletionListener,以便在启动视频完成时调用选项卡Activity(包含所有内容)。问题是,在播放视频后,不会调用下一个活动。这是代码:
package com.companyname.cpny;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.widget.VideoView;
public class splash extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView vs = (VideoView) findViewById(R.id.imlsplash);
Uri uri = Uri.parse("android.resource://"+getPackageName() + "/"+R.raw.iphonesplashfinal);
vs.setVideoURI(uri);
vs.start();
vs.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
Intent main = new Intent(splash.this, tabhost.class);
splash.this.startActivity(main);
splash.this.finish();
}
});
}
}
答案 0 :(得分:1)
你能试试吗
vs.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
splash.this.runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
Intent main = new Intent(splash.this, tabhost.class);
splash.this.startActivity(main);
splash.this.finish();
}
});
}
编辑: 您是否可以先注册听众,然后再打电话开始。
vs.start()