Chris Fillmore

01/27/2023, 4:44 PM
I am in the following situation: • My app uses the camera • When the app is backgrounded, it goes into PiP • It’s possible the user has a bottom sheet open when they go to background • I am using compose navigation with
destinations How can I hide the bottom sheet when I go into PiP? I don’t really want to dismiss the bottom sheet, since I want to resume at full screen with the same back stack. Any ideas?
Currently my camera preview is coupled with my start destination, sorta like:
fun MyApp() {
  ModalBottomSheetLayout {
    NavHost {
      composable("MAIN") {
      bottomSheet("MY_SHEET") {
The obvious solution is to pull the camera preview out of the “MAIN” composable. But I do actually want it scoped to the lifecycle of that back stack entry. I suppose I would have to add some signalling through a new layer, that would mediate closing the camera and such, and disposing of the SurfaceView, etc. Or is there another solution I’m missing?