Last active
September 21, 2019 16:34
-
-
Save TroyStopera/df479e24245fa887db8acdc0da5f9a1e to your computer and use it in GitHub Desktop.
Start activity helper
This file contains hidden or 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 <T : Activity> Activity.startActivity( | |
activityClass: KClass<T>, | |
intentBlock: (Intent.() -> Unit)? = null | |
) { | |
val intent = Intent(this, activityClass.java) | |
intentBlock?.invoke(intent) | |
startActivity(intent) | |
} |
This file contains hidden or 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
fun launchMainActivity() { | |
startActivity(MainActivity::class) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment