Assigned
Status Update
Comments
su...@google.com <su...@google.com>
pi...@google.com <pi...@google.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.
be...@gmail.com <be...@gmail.com> #3
Turns out, we already had a tracking bug for this issue, will follow up on that other one.
em...@audi.de <em...@audi.de> #4
Thank you for promptly replying to my report. You are right that the issue you've just mentioned is similar to mine. I shall continue observing the progress over there.
Description
slices/core/src/main/java/androidx/slice/SliceProvider.java
Version used:
androidx.slice:slice-core:1.1.0-alpha01
androidx.slice:slice-view:1.1.0-alpha01
Devices/Android versions reproduced on:
Automotive Emulators
Description:
The demonstrator "SliceViewerKotlin" defines a provider and a viewer for slices. Both are located in the same app.
The unpin/pin behavior of slices is as following:
- assuming one slice is being displayed in a one-slice-viewer and it has been pinned
- this slice is getting unpinned:
--> if this slice is replaced by another one
--> if the user leaves the viewer-app i.e. he moves to any other app
This behavior is fine.
Now, put the provider in a separate app:
- the pinned slice is NOT getting unpinned in both situations from above
- the slice is unpinned, when the app is manually stopped
Why a different behavior? Is it a bug?
4 attachments:
- project "SliceViewerKotlin.zip" - after I´ve adapted it slightly as a "one-slice-viewer"
- project "StandaloneSliceProvider.zip" - similar to above but it only contains a provider and an empty Activity to enable any SliceAction
- log "PlayingWithProvider_in_SliceViewerKotlin.txt" to illustrate the unpin-behavior when both presenter and provider are in the same app
- log "PlayingWith_Standalone_Provider.txt" to illustrate the unpin-behavior when both presenter and provider are NOT in the same app