You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android WearOS API是否提供读取手部佩戴偏好(左右手、按钮侧)的函数?

Wear OS 获取佩戴偏好(手腕位置与按钮朝向)的API说明

Wear OS 提供了官方API来获取用户的手表佩戴偏好,对应你提到的iOS wristLocation 相关功能,具体如下:

1. 获取手腕佩戴位置(左手/右手)

你可以通过两种方式获取该信息:

方式一:通过系统设置项读取

直接读取系统安全设置中的对应字段:

import android.content.ContentResolver
import android.provider.Settings

fun getWristPosition(contentResolver: ContentResolver): String? {
    // 返回值为 "left" 或 "right"
    return Settings.Secure.getString(contentResolver, "wear_os_wrist_preference")
}

方式二:通过 WearableDeviceInfo 类(推荐,类型安全)

在较新的 Wear OS 版本中,使用官方封装的类来获取类型化的结果:

import android.content.Context
import com.google.android.wearable.compat.Wearable
import com.google.android.wearable.compat.WearableDeviceInfo

fun getWristPreference(context: Context): WearableDeviceInfo.WristPreference? {
    val deviceInfo = Wearable.getDeviceInfo(context)
    return deviceInfo?.wristPreference
    // 返回值为 WristPreference.LEFT 或 WristPreference.RIGHT
}

2. 获取按钮朝向(朝向手部/肘部)

同样有两种获取方式:

方式一:通过系统设置项读取

import android.content.ContentResolver
import android.provider.Settings

fun getButtonOrientation(contentResolver: ContentResolver): String? {
    // 返回值为 "toward_hand" 或 "toward_elbow"
    return Settings.Secure.getString(contentResolver, "wear_os_button_orientation")
}

方式二:通过 WearableDeviceInfo 类(推荐)

import android.content.Context
import com.google.android.wearable.compat.Wearable
import com.google.android.wearable.compat.WearableDeviceInfo

fun getButtonPlacement(context: Context): WearableDeviceInfo.ButtonOrientation? {
    val deviceInfo = Wearable.getDeviceInfo(context)
    return deviceInfo?.buttonOrientation
    // 返回值为 ButtonOrientation.TOWARD_HAND 或 ButtonOrientation.TOWARD_ELBOW
}

这些API完全对应iOS中 WKInterfaceDeviceWristLocation 和 WKInterfaceDeviceCrownOrientation 的功能,是官方支持的获取佩戴偏好的标准方式。

内容的提问来源于stack exchange,提问作者Adam Hoover

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 01:42:43