Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
Your attached project wasn't in the same state that your video showed, but I was able to reproduce the issue.
The issue is specifically the clear task flag and Activity destinations - the first activity should be removed from the stack when you use the clear task flag (as you specifically asked us to clear the entire task stack before going to the new activity). I've updated the title to match the actual issue.
The reason you get a IllegalArgumentException when coming back to the Activity that isn't supposed to exist is that all existing destinations are popped off NavController's stack (clearing the stack). This means the Acitivity, from the NavController's point of view, isn't on the FirstFragment anymore (it is only an artifact of Fragments that it is shown at all).
The issue is specifically the clear task flag and Activity destinations - the first activity should be removed from the stack when you use the clear task flag (as you specifically asked us to clear the entire task stack before going to the new activity). I've updated the title to match the actual issue.
The reason you get a IllegalArgumentException when coming back to the Activity that isn't supposed to exist is that all existing destinations are popped off NavController's stack (clearing the stack). This means the Acitivity, from the NavController's point of view, isn't on the FirstFragment anymore (it is only an artifact of Fragments that it is shown at all).
[Deleted User] <[Deleted User]> #3
Hi. Thanks for the response and explanation. It's clear to me now. :) And, sorry, my bad, I think I had changed a few things in the project for testing rest of the functionality, hence it wasn't in the same state.
il...@google.com <il...@google.com> #4
We've taken a strong look at the clear task flag and have decided to remove it for alpha02, instead preferring the much more explicit signal of setting a popUpTo destination. This should remove the confusion around the use of this flag with activity destinations going forward.
il...@google.com <il...@google.com> #5
I should clarify: we're deprecating it in alpha02, removing it in a future version.
[Deleted User] <[Deleted User]> #6
Hi. Thanks for the clarification. Looking forward to the next release. :)
lo...@gmail.com <lo...@gmail.com> #7
I got a question regarding the removal of clearTask: originally I have been using clearTask to make sure prevent the user from going back to a splashFragment (see https://stackoverflow.com/questions/50336112/how-to-disable-up-in-navigation-for-some-fragment-with-the-new-navigation-archit/50336319 ). What should I do instead to clear previous fragments from the stack?
mu...@gmail.com <mu...@gmail.com> #8
[Deleted User] <[Deleted User]> #9
Your destinationId in setPopUpTo need to be either id of the graph itself or better be id of the startDestination. You can also achieve this behavior with navigation graph xml attributes popUpTo and popUpToInclusive.
[Deleted User] <[Deleted User]> #10
I'm trying to use popUpTo with popUpToInclusive exactly as instructed, and it works fine for normal actions. However, I can't get it to work for global actions! Clear Task used to work perfectly for global actions.
il...@google.com <il...@google.com> #11
Re #10 - please file a new bug with a sample project that reproduces your issue.
[Deleted User] <[Deleted User]> #12
Re #11 I created a new issue detailing my problem and containing a sample project here: https://issuetracker.google.com/issues/116831650
h....@gmail.com <h....@gmail.com> #13
ok
Description
DETAILS:-
The destination home is an activity with a NavHostFragment (FirstFragment.kt) which initially navigates to the second destination (SecondActivity.kt), then immediately comes back to the FirstFragment, and then navigates to third destination (FirstPopupFragment.kt). (Navigation can be observed in the attached screen-record).
LOG:-
2018-05-27 20:39:52.794 3289-3289/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.cyrilnoah.navigationegapp, PID: 3289
java.lang.IllegalArgumentException: navigation destination com.example.cyrilnoah.navigationegapp:id/action_first_to_first_popup is unknown to this NavController
at androidx.navigation.NavController.navigate(NavController.java:605)
at androidx.navigation.NavController.navigate(NavController.java:565)
at androidx.navigation.NavController.navigate(NavController.java:553)
at com.example.cyrilnoah.navigationegapp.FirstFragment$onViewCreated$1.onClick(FirstFragment.kt:40)
at android.view.View.performClick(View.java:6579)
at android.view.View.performClickInternal(View.java:6556)
at android.view.View.access$3100(View.java:777)
at android.view.View$PerformClick.run(View.java:25660)
at android.os.Handler.handleCallback(Handler.java:819)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Component used:
"android.arch.navigation:navigation-fragment-ktx:$nav_version"
"android.arch.navigation:navigation-ui-ktx:$nav_version"
Version used:
nav_version = '1.0.0-alpha01'
Devices/Android versions reproduced on:
Tested on Pixel 2 XL (emulator), and Xiaomi Mi Max 2 (real device). Probably crashes on all, not so sure.
- Sample project to trigger the issue.
(Project attached below)
- A screenrecord or screenshots showing the issue (if UI related).
(Screen-record attached below)