You know It's official now: Google officially recommends single activity app architecture. But there is a difficulty here. We have multiple activities. So when I want to implement Navigation with multiple activities, but I failed.
They said: In cases where multiple Activities share the same layout, the navigation graphs can be combined, replacing navigate calls to the activity destination to navigate calls directly between the two navigation graphs. in here
So I create this :
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:startDestination="@+id/nav_graph_firstActvity">
<activity
android:id="@+id/nav_graph_firstActvity"
android:name="io.androidedu.FirstActivity"
android:label="First Activity">
<action
android:id="@+id/nav_graph_actFirstActvity"
app:destination="@id/nav_graph_secondActvity" />
</activity>
<activity
android:id="@+id/nav_graph_secondActvity"
android:name="io.androidedu.SecondActivity"
android:label="Second Activity" />
After that i can not find any sample for multiple activities in here. There is some sample like that :
Navigation.findNavController(view).navigate(R.id.nav_graph_actFirstActvity)
But findNavController() wait for a view, not an activity.
How can I solve this folks?