9

I want to do simple transition between 2 states using navigation but I have 1 issue:

When user starts application an welcome screen is presented with 1 button that should take to the login screen.

After user clicks that button he is taken to login screen and backstack needs to be removed so when user clicks back button he's taken out of application entirely instead of previous screen.

I have implemented this workflow and it works, but the issue is that after clicking button poping of the stack is visible to the user.

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/welcome_nav"
    app:startDestination="@id/welcome_fragment">

    <fragment
        android:id="@+id/welcome_fragment"
        android:name="com.domain.example.WelcomeFragment"
        android:label="WelcomeFragment"
        tools:layout="@layout/welcome_screen">
        <action
            android:id="@+id/action_to_login_nav"
            app:destination="@id/access_nav"
            app:enterAnim="@anim/nav_default_enter_anim"
            app:exitAnim="@anim/nav_default_enter_anim"
            app:popUpTo="@id/welcome_fragment"
            app:popUpToInclusive="true" />
    </fragment>

    <include app:graph="@navigation/login_nav" />

</navigation>

PS. What I mean by saying that poping of the backstack is visible is that: For a short amout of time login destination is visible then previous destination is visible again and then login destination is visible once more, this happens fast but with transition animation it visible as state flickering.

antanas_sepikas
  • 5,644
  • 4
  • 36
  • 67
  • 1
    Did you ever find a solution to this? I'm having the same issue. The only real solution I've found is to not use animations and then popUpTo works great. But with animations, popUpTo seems broken. – Greg Moens Mar 18 '19 at 20:14
  • 1
    By the way, found another stack overflow about this same thing. No luck over there either. https://stackoverflow.com/questions/53976785/android-navigation-component-pop-to-transition-issue – Greg Moens Mar 18 '19 at 21:02

0 Answers0