Skip to content

Navigation on Activities

Jeziel Lago edited this page Jan 10, 2020 · 3 revisions

Declare your entry point activities

On each feature-module on your project, you need to add EntryFlowNav annotation to inform what activities are the feature-module entry point. The annotation receives a string to identify the activity.

@EntryFlowNav("feature_one")

We recommend that you create constants on navigation module for reuse these strings and prevent typo errors.

@EntryFlowNav(FEATURE_ONE)
class MyFirstOneActivity : AppCompatActivity() { ...

Start Activities

To get the expected intent for the navigation, we need to use a context extension function named start and who expects the same string used on @EntryFlowNav.

  • start(FEATURE_ONE) call startActivity(...)

  • startForResult(FEATURE_ONE, REQUEST_CODE) call startActivityForResult(...)

If you need to pass some arguments to the intent, we will open lambda on second param.

start(FEATURE_TWO) { 
    putString("key", arg)
}

And then, we can call...

myButton.setOnClickListener {
    // redirect to "FEATURE 1"
    start(FEATURE_1)
}
Clone this wiki locally