如何在一个视频播放完后转到另一个activity?

How to move to another activity after a video is finished?

如果用户转到主屏幕并 return 在视频播放完毕后转到应用程序,我会尝试增加延迟时间。我希望应用程序移动到下一个 activity。我该怎么做?

我当前的代码:

class MainActivity : AppCompatActivity() {
var currentp=0
var tmi:Long=7000
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        var inte= Intent(this,Main_menu::class.java)
        window.setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN
        )
        va.setBackgroundColor(Color.TRANSPARENT);

        val videoview : VideoView = va

        val uri = Uri.parse("android.resource://" + packageName + "/" + R.raw.intro)
        videoview.setVideoURI(uri)
        va.setZOrderOnTop(true)
        videoview.start()

        Handler().postDelayed({

    startActivity(inte)},7000)
}
     override fun onPause() {
        super.onPause()
currentp=va.currentPosition

     }

     override fun onStop() {
        super.onStop()
    }

    override fun onStart() {
        super.onStart()

    }

    override fun onResume() {
        super.onResume()
if(currentp!=0 && currentp!=100){
    va.seekTo(currentp)
        va.start()}
    }

JAVA

videoView.setOnCompletionListener(completionListener);
OnCompletionListener completionListener = new OnCompletionListener(){

        public void onCompletion(MediaPlayer mp) {
            Intent intent = new Intent(CurrentActivity.this, NextActivity.class);
            startActivity(intent); 
        }
    };

我通常在 Java 中编码,但我尝试在 Kotlin 中转换它,如果有问题请指正。

KOTLIN

videoView.setOnCompletionListener{

            var intent = Intent(this, MainMenu::class.java)                
            startActivity(intent); 
        }
    };

现在你应该拥有走上正确道路的一切。干杯!