https://kotlinlang.org logo
#compose-wear
Title
# compose-wear
a

Ahmet Hasim Delibas

09/19/2023, 6:33 PM
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

stevebower

09/21/2023, 12:39 PM
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

Ahmet Hasim Delibas

09/21/2023, 1:03 PM
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

stevebower

09/21/2023, 1:15 PM
Glad that helps. Interested to know why you describe it as not a stable solution?
a

Ahmet Hasim Delibas

09/21/2023, 1:19 PM
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

Ian Lake

09/21/2023, 10:14 PM
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
3 Views