Playing with the new fragment navigation, I wanted to dump the current backstack to the log for information purposes to learn how it all works. The problem is, when I obtain the NavController, it doesn't appear to have any of the backstack properties or functions.
Here's a simple example:
class MyFragment: Fragment() {
...
override fun onResume() {
super.onResume()
// Dump the back stack
Log.i("MyFragment", findNavController().currentBackStackEntry?.destination.label)
}
...
In Studio, currentBackStackEntry is not found. It's also true for backStackEntry and previousBackStackEntry (or using the functions explicitly). Of course, when compiling, I get an unresolved reference error.
I'm using:
- Android Studio 4.1.1
- Kotlin plugin 1.4.10
- navigation-fragment-ktx & navigation-ui-ktx 2.3.1
I can use other functions/properties with the NavController, such as obtaining the graph. It's only the *backStack* properties that don't seem to exist.
So, the question is why aren't those properties available, yet documented (they're supposed to be there since navigation-*:2.2.0) and do others see the same issue?