I'm a beginner to Kotlin language. I have trouble redirection to another activity after for example 4 seconds. I know how to do it in Java but I have no idea about Kotlin. I use android studio version 2019.
I tried android studio's converter (Java to Kotlin) I couldn't find an answer which lead me to an answer that could redirect me from an activity to another by DELAY. I'm not asking about other ways of redirecting I'm asking exactly about delay. I mean how to go to another page in an android program not clicking any button or something.
edit (Sep 13): unfortunately I'm still struggling with the problem. I tried to use this code but It doesn't work. Can you please tell me what is the problem: MainActivity.kt:
package com.rearaa.weading
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
val handler = Handler()
val runnable = Runnable {
val i = Intent(this@MainActivity, MenuPage::class.java)
startActivity(i)
}
handler.postDelayed(runnable, 4000)
}
In above code I want to redirect from MainActivity to MenuPage.