Adam Hoover
Adam Hoover

Reputation: 39

Android WearOS API function to get hand settings (left/right, watch button side)

Does the Android WearOS API provide a function to read the hand preference settings? We want to know if the user is wearing the watch on their left or right hand, and which side the button is on (towards the hand or towards the elbow).

Apple provides the wristLocation function which includes WKInterfaceDeviceWristLocation for the wrist (left or right) and WKInterfaceDeviceCrownOrientation for button side. Where can this info be found in the Android WearOS API?

We cannot find the same type of function in Android WearOS.

Upvotes: 3

Views: 133

Answers (2)

Flore
Flore

Reputation: 191

If you just need to know if the watch is worn upside down. ie: crown/buttons on the left instead of the right, which results in the screen being reversed 180 degree.

In this case you can look at the USER_ROTATION system setting

boolean isReversed = Settings.System.getInt(context.getContentResolver(),
    Settings.System.USER_ROTATION, Surface.ROTATION_0) == Surface.ROTATION_180;

This however does not indicates which hand is the watch on, even though most of the time a reversed screen would indicate that the watch is worn on the right hand

Upvotes: 1

Marsroverr
Marsroverr

Reputation: 746

The most likely place for checking which wrist a device is on would be Health Services, however it seems the API doesn't expose any data on which wrist the user is wearing the device. I'd suggest asking your user this and saving it as an app setting.

You can, however, get info about physical buttons on a WearOS device using the Wear Input library, where getLocationZone() will tell you where on a device a given button is located. You can even use this to derive whether the device is round or square based on how it reports the button location.

Example code:

val buttonInfo = WearableButtons.getButtonInfo(activity, KeyEvent.KEYCODE_STEM_1)

buttonInfo.getLocationZone()

Note that this will have to be done dynamically by your app whenever you need to do something with a button location - Unlike the Apple Watch, every WearOS device has different locations and even amounts of buttons and you can't guarantee that a user will use the same watch with your app every time.

Upvotes: 0

Related Questions