https://kotlinlang.org logo
#navigation-architecture-component
Title
# navigation-architecture-component
y

Yasutaka Kawamoto

03/13/2024, 12:52 AM
Hello, I'm using androidx.navigation:navigation-*:2.7.5 and noticed a potential issue with NavController#onGraphCreated not being called when calling setGraph twice. This seems to be related to the commit found here: https://android.googlesource.com/platform/frameworks/support/+/d22366d59a46aa16aa79d1d691cd5cb55f56c378 I'm trying to find a way to force NavController#onGraphCreated to be called in this scenario. Here's why I need this: I have an Activity with launchMode set to singleTop. • When the Activity is started for the first time, onCreate is called and NavController#setGraph is used to set the initial graph. • When the Activity is started again (via startActivity), onNewIntent is called. Inside onNewIntent, I call NavController#setGraph again to update the UI. This worked fine in 2.7.4, but in 2.7.5, the UI no longer updates when calling setGraph in onNewIntent. Is there any way to force NavController#onGraphCreated to be called in this situation? Any help would be greatly appreciated.
d

dave08

04/09/2024, 10:55 AM
Did you ever solve this problem? I think I'm maybe having a similar problem...
y

Yasutaka Kawamoto

04/13/2024, 1:42 PM
We haven't resolved this issue yet, and we're considering the following. Is the launchMode of the Activity you're having an issue with set to singleTop? If so, I'm considering removing the singleTop mode. If we do that, this article might be helpful: https://medium.com/@douglas.iacovelli/android-send-result-back-through-multiple-activities-finished-or-not-4c2ba9e95112 However, in our project, it's problematic if Activities stack up, so I'm currently considering how to handle that.
3 Views