'Switch between activities but global function
I want to create a global function and I want to switch between activities with this function. Extensions.kt
fun goActivity(context: Context, goClass: Class<Any>) {
val homeIntent = Intent(context, goClass)
homeIntent.flags =
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
context.startActivity(homeIntent)
(context as Activity).finish()
}
anyActivity
goActivity(context,HomeActivity::class.java)
erromessage Type mismatch: inferred type is Class but Class was expected
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
