Использование компонента навигации Android. У меня есть два навигационных графика (каждый из них со своим собственным потоком), скажем, навигационные графы A и B. Я успешно перехожу от A к B, но мне не удается передать аргумент из последнего фрагмента, включенного в график A, в стартовый фрагмент, принадлежащий графу B.
Я могу передавать аргументы между фрагментами, принадлежащими одному и тому же графу, но функция для установки аргументов не генерируется при переходе между графами навигации.
Я пытаюсь сделать это с помощью safeargs.
Вот код навигационных графиков:
График навигации A:
<navigation android:id="@+id/nav_graph_a"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:startDestination="@id/fragment1">
<fragment
android:id="@+id/fragment1"
android:name="com.mypackage.fragments.Fragment1"
android:label="Fragment1">
<action
android:id="@+id/action_fragment1_to_fragment2"
app:destination="@id/fragment2"/>
</fragment>
<fragment
android:id="@+id/fragment2"
android:name="com.mypackage.fragments.Fragment2"
android:label="Fragment2">
<argument
android:name="thisArgumentAlwaysArrive"
android:defaultValue="null"
app:argType="string"/>
<action
android:id="@+id/action_fragment2_to_nav_graph_b"
app:destination="@id/nav_graph_b"/>
</fragment>
<include app:graph="@navigation/nav_graph_b"/>
Navigation Graph B:
<navigation android:id="@+id/nav_graph_b"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:startDestination="@id/fragment3">
<fragment
android:id="@+id/fragment3"
android:name="com.mypackage.fragments.Fragment3"
android:label="Fragment3">
<argument
android:name="thisArgumentNeverArrive"
app:argType="string"/>
</fragment>
Any idea on how to accomplish this?