Assigned
Status Update
Comments
vi...@google.com <vi...@google.com>
go...@gmail.com <go...@gmail.com> #2
This actually has nothing to do with NavHostFragment, but is the behavior of NavController's setGraph().
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
sl...@google.com <sl...@google.com>
ae...@google.com <ae...@google.com> #3
Turns out, we already had a tracking bug for this issue, will follow up on that other one.
Description
Version used: 1.2.0
Devices/Android versions reproduced on: Samsung SM-A510F
Project attached...
- I have a module `client`, an android library with the front end code.
- I have the module `app`, the android application where I write the instrumented tests.
- I have a flavor `automation` for which I use to run my instrumented tests and it has test implementations of activities should they be needed.
The package in app, `androidTestAutomation` is where my Instrumented tests are located.
When I run the following test: com.github.goldy1992.mp3player.client.views.fragments.PlaybackTrackerFragmentTest I get the error in `stacktrace.txt`.
All google search results refer to the inclusion of:
`debugImplementation group: 'androidx.fragment', name: 'fragment-testing', version: FRAGMENT_VERSION`
I've tried different combinations in both the app and client `build.gradle` file but everything results in the same error.
EXPECTED result: `FragmentScenario$EmptyFragmentActivity` should be configured correctly by Gradle and therefore recognised in the instrumented test.