Here is my code
<fragment
android:id="@+id/fragment1"
android:name="com.example.app.Fragment1"
android:label="SignatureFragment"
tools:layout="@layout/layout_fragment1">
<action
android:id="@+id/action_fragment1_to_main_activity"
app:destination="@id/main_activity"
app:enterAnim="@anim/slide_in_from_right"
app:exitAnim="@anim/no_anim"
app:launchSingleTop="true"
app:popEnterAnim="@anim/no_anim"
app:popExitAnim="@anim/slide_out_to_right"
app:popUpTo="@id/navigation_graph_id"
app:popUpToInclusive="true" />
</fragment>
<activity
android:id="@+id/main_activity"
android:name="com.example.app.MainActivity"
android:label="MainActivity"
tools:layout="@layout/activity_main" />
Now the code for navigation
findNavController().navigate(R.id.action_fragment1_to_main_activity)
When I navigate to activity and press back, the fragment
is still there. I want to clear the backstack after opening the activity.
I tried to remove the animation and also tried with removing app:launchSingleTop
, but no success.