【发布时间】:2022-12-15 03:01:38
【问题描述】:
我有两个 Android 应用程序(手机/手表),如果手表上安装了磨损应用程序,我想检查移动应用程序。
有什么想法吗?
我搜索但没有结果。
【问题讨论】:
标签: android mobile watchkit wear-os
我有两个 Android 应用程序(手机/手表),如果手表上安装了磨损应用程序,我想检查移动应用程序。
有什么想法吗?
我搜索但没有结果。
【问题讨论】:
标签: android mobile watchkit wear-os
Detect your app on another device中有描述,Github中也有示例。
简而言之,您应该:
res/values/wear.xml 文件添加到您的手表模块,指定您应用的功能:
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@array/android_wear_capabilities">
<string-array name="android_wear_capabilities">
<item>your_custom_app_capability</item>
</string-array>
</resources>
val capabilityClient = Wearable.getCapabilityClient(this)
capabilityClient.addListener({ capabilityInfo -> {
// the watch with the wear app that contains
// your custom capability can be retrieved from:
capabilityInfo.nodes
} }, "your_custom_app_capability")
【讨论】: