Created
April 27, 2023 05:52
-
-
Save akshaykalola28/594444ef2c14748a326a4432e7ed1a81 to your computer and use it in GitHub Desktop.
Extension functions for Start Activity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity | |
import android.content.Intent | |
fun Activity.startActivity( | |
cls: Class<*>, | |
finishCallingActivity: Boolean = true, | |
block: (Intent.() -> Unit)? = null | |
) { | |
val intent = Intent(this, cls) | |
block?.invoke(intent) | |
startActivity(intent) | |
if (finishCallingActivity) finish() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment