Fixed
Status Update
Comments
ai...@gmail.com <ai...@gmail.com> #2
I'm still having the same issues in:
Android Studio 3.3 Canary 12
Build #AI-182.4505.22.33.5026711, built on September 24, 2018
JRE: 1.8.0_152-release-1248-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6
Android Studio 3.3 Canary 12
Build #AI-182.4505.22.33.5026711, built on September 24, 2018
JRE: 1.8.0_152-release-1248-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6
th...@gmail.com <th...@gmail.com> #3
Any updates on this? Have you been able to reproduce it? It's a release blocker on our end ā any resonable workaround would be appreciated.
ai...@gmail.com <ai...@gmail.com> #4
I think I have an idea of what is going on. Do you see a Log.INFO message saying: "Ignoring popBackStack to destination __ as it was not found on the current back stack"? If so, that means we're doing exactly what you said - popping id/graph off the stack - but not actually what you want (the parent graph to continue to be around if you are navigating forward as well)
If so, one workaround is to use popUpTo="@+id/a" and popUpTo"@+id/b" for action x and y, respectively - if you know that x is always clearing A off the stack, then popUpTo B is enough.
If so, one workaround is to use popUpTo="@+id/a" and popUpTo"@+id/b" for action x and y, respectively - if you know that x is always clearing A off the stack, then popUpTo B is enough.
wk...@google.com <wk...@google.com>
ap...@google.com <ap...@google.com> #5
Alright, interesting! So that means there is no generic way to say that "clear everything of the backstack before moving to this next destination"? Rather, you need to keep track of every individual case? What if, for example, you have to following graph:
x y z
A --> B --> C --> D
Where
- A could be a splash screen and the start destination of the graph
- B could be some welcome screen, prompting the user to sign in
- C could be the actual login screen where the user enters his/hers details and signs in
- D could be the main content screen
Obviously the user should not be allowed to click the back button from B to go back to the splash screen, and neither should the user be allowed to click the back button from D to go back to the login screen. In both of these cases the user should instead exit the app. However, it's perfectly fine for the user to click back from C and go back to the welcome screen B.
Now, to the problem; with your suggested workaround we can indeed set popUpTo="@+id/a" on x, but if we set popUpTo="@+id/c" on z then the user can still click the back button, but they will go to B instead. The desired behaviour is for the user to exit the app when clicking back when in D. The workaround stops working as we don't pop the back stack when going from B --> C, as we want to allow the user to navigate back to B from C.
x y z
A --> B --> C --> D
Where
- A could be a splash screen and the start destination of the graph
- B could be some welcome screen, prompting the user to sign in
- C could be the actual login screen where the user enters his/hers details and signs in
- D could be the main content screen
Obviously the user should not be allowed to click the back button from B to go back to the splash screen, and neither should the user be allowed to click the back button from D to go back to the login screen. In both of these cases the user should instead exit the app. However, it's perfectly fine for the user to click back from C and go back to the welcome screen B.
Now, to the problem; with your suggested workaround we can indeed set popUpTo="@+id/a" on x, but if we set popUpTo="@+id/c" on z then the user can still click the back button, but they will go to B instead. The desired behaviour is for the user to exit the app when clicking back when in D. The workaround stops working as we don't pop the back stack when going from B --> C, as we want to allow the user to navigate back to B from C.
wk...@google.com <wk...@google.com>
il...@google.com <il...@google.com> #6
It would be interesting to have a "popAll" option, where the whole stack will be erased, so we don't have to keep track who's on the stack to be popped or not. It would speed up things and bring less confusion as well.
b9...@gmail.com <b9...@gmail.com> #7
I agree completely, similarly to how clearTask worked before it was deprecated.
il...@google.com <il...@google.com> #8
A couple of points:
1) There really is a bug here - app:popUpTo="@+id/graph" should work as well - that's why I said 'workaround' above, not solution. We will be fixing that bug.
2) Popping everything off the stack is always a sign that you've built your graph incorrectly. That's on us though as we haven't documented well enough how to do conditional navigation (for example, the B->C sign in flow).https://issuetracker.google.com/issues/111762510 is our tracking bug for updating the conditional navigation page (https://developer.android.com/topic/libraries/architecture/navigation/navigation-conditional ).
For example, in the example raised in #5, your start destination should be D.
- Splash screen should be using a splash theme (e.g.,https://www.bignerdranch.com/blog/splash-screens-the-right-way/ ) and not be in your graph at all
- B+C should be handled as conditional navigation from D - D starts B and if you return to D without logging in, D calls finish().
- Having D as your startDestination is critical to having the right back stack when deep linking to somewhere in your graph
I realize that this is a bigger mental shift from how you've structured your apps and is a big reason why improving the documentation is an important focus for Navigation over the next few months.
1) There really is a bug here - app:popUpTo="@+id/graph" should work as well - that's why I said 'workaround' above, not solution. We will be fixing that bug.
2) Popping everything off the stack is always a sign that you've built your graph incorrectly. That's on us though as we haven't documented well enough how to do conditional navigation (for example, the B->C sign in flow).
For example, in the example raised in #5, your start destination should be D.
- Splash screen should be using a splash theme (e.g.,
- B+C should be handled as conditional navigation from D - D starts B and if you return to D without logging in, D calls finish().
- Having D as your startDestination is critical to having the right back stack when deep linking to somewhere in your graph
I realize that this is a bigger mental shift from how you've structured your apps and is a big reason why improving the documentation is an important focus for Navigation over the next few months.
b9...@gmail.com <b9...@gmail.com> #9
So if I understand this correctly, D is a Fragment and it should call its Activity (the one and only one in the app) finish(), in case there's something wrong, like going back from the login screen?
I find this complicated and can lead to issues that resemble "callback hell", having multiple checks and flags everywhere, to know if we already navigates to some destination and if we are back and without a proper value... Can't we come up with a more streamlined solution?
I find this complicated and can lead to issues that resemble "callback hell", having multiple checks and flags everywhere, to know if we already navigates to some destination and if we are back and without a proper value... Can't we come up with a more streamlined solution?
Description
Version used: 1.0.0-alpha02
As an expansion on