-
Notifications
You must be signed in to change notification settings - Fork 3
Android Activity Integration
Thiago Santos edited this page Aug 15, 2024
·
1 revision
Important
This module is a case of studies that shows how you can extend Kotlin Routing to your context.
The android module provides plugin and handlers to manager starting an Activity.
sourceSets {
androidMain.dependencies {
implementation("dev.programadorthi.routing:android:$version")
}
}
Installing the android activities plugin needs to provide the current Context.
val router = routing {
install(AndroidActivities) {
context = youCurrentContextInstance
}
}
val router = routing {
activity(path = "...") {
Intent(call.currentActivity, Activity::class.java)
}
}
router.call(uri = "...")
// or
router.pushActivity(path = "...")
router.replaceActivity(path = "...")
router.replaceAllActivity(path = "...")
router.popActivity()
router.pushActivity(path = "...", requestCode = requestCode)
router.popActivity(result = Intent())
router.pushActivity(
path = "...",
activityOptions = ActivityOptions.makeBasic().toBundle(),
)
@Resource("/articles")
class Articles()
val router = routing {
install(Resources)
install(AndroidActivities) {
context = youCurrentContextInstance
}
}
val router = routing {
// ...
activity<Articles> {
Intent(call.currentActivity, Activity::class.java)
}
}
router.pushActivity(resource = Articles())
And, of course, if you need to get a result from an activity just follow the official docs.