Java 调用setVideoUri时活动未立即完成
我的活动中有一个视频视图,当用户按play时,我使用了Java 调用setVideoUri时活动未立即完成,java,android,Java,Android,我的活动中有一个视频视图,当用户按play时,我使用了 videoView.setVideoURI(uri); video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { public void onPrepared(MediaPlayer mp) { progressBar.setVisibility(View.INVISIBLE); mp.start();
videoView.setVideoURI(uri);
video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
progressBar.setVisibility(View.INVISIBLE);
mp.start();
}
});
这很好用,我使用了一个按钮停止并退出屏幕
videoView.stopPlayback();完成()代码>但活动onDestroy()未立即调用,如果再次启动该活动,则该活动会一直持续,直到您打开该活动时前一个onDestroy调用时才会将该标志设置为
Intent intent = new Intent(Login.this, Dashboard.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
当您打开该活动时,将该标志设置为
Intent intent = new Intent(Login.this, Dashboard.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);