`BackHandler` does not catch backs via swiping (in...
# compose-wear
a
BackHandler
does not catch backs via swiping (in
SwipeDismissableNavHost
), as it does in mobile side. Now I need to do some arrengements onBackHandler, how could I do this in wear OS?
s
Hi - swiping back is handled as navigating back to the previous screen in SwipeDismissableNavHost. What's the functionality you're trying to get?
If you are trying to add additional handling when the user swipes to navigate back, there's some code here that shows how to do that: https://issuetracker.google.com/issues/292590712#comment4
a
Hello Steve. I am looking for a
BackHandler
which handles swipe back events too. Right now back events via swiping is not caught by
BackHandler
, so I can’t override the process for wear OS (as I do in mobile development).
If you are trying to add additional handling when the user swipes to navigate back, there’s some code here that shows how to do that: https://issuetracker.google.com/issues/292590712#comment4
Hmm that might work for me too
It’s not a stable solution, but definitely a better workaround than mine. Thank you so much Steve
s
Glad that helps. Interested to know why you describe it as not a stable solution?
a
I mean, as in traditional development, or Jetpack Compose for mobile, I was expecting that it catches all the back events: https://developer.android.com/jetpack/compose/libraries#handling_the_system_back_button However, it miss swiping back event
i
Yep, Wear OS doesn't trigger any of the system back APIs that exist on phones, tablets, TVs, etc. - neither the (now deprecated)
onBackPressed()
or anything else built on that infrastructure like
BackHandler
. That's always been the case. The Wear team is aware (ha) of that difference, but it is a difference that is baked into the current version of Wear OS itself, so even if it were to change, it would only apply to that hypothetical newer version of Wear