I suppose that you finish Activity A when you launch Activity B, otherwise you would still have the fragment B visible int the Activity A (as you left it). But try to put an extra in the intent of the Activity B that launches the Activity A that says which fragment should be active in that Activity. That way, when the Activity A is created, you can check the bundle, check if there is any information about which fragment should be visible, and, if so, set the fragment as visible.
Navigating up from an activity to a specific fagment in the parent activity
-
29-06-2023 - |
質問
I'm trying to make the UP button provide back navigation to a specific fragment in the parent activity.
Activity1 contatins FragmentA
and FragmentB
. You can launch Activity2 from FragmentB
.
Activity1 is declared as the parent of Activity2 in the Manifest file.
<activity
android:name="com.example.Activity2"
android:parentActivityName="com.example.Activity1" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.Activity1" />
</activity>
When you're in Activity2 and press UP button, I want you to return to FragmentB
in Activity1.
Instead, it returns to FragmentA (because it's the default fragment in Activity1).
Thank you in advance.
解決
所属していません StackOverflow