How to pass activity to a function in kotlin I have buttons that pass one activity to another so I want to write intent in a function in order to do that I have to pass activity to which we need to go after pressing the button. So how can I pass activity to a function in kotlin?
I know how to move from one activity to another .I just want to know if I want Activity in parameter what to write here in kotlin: private fun replaceActivity(what to write here) –
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
replaceActivity(MenuActivity())
}
fun replaceActivity(activity: Activity) {
val intent = Intent(this, activity::class.java)
startActivity(intent)
}
replaceActivity(MenuActivity::class.java) this is how I am calling the function