【问题标题】:Android: check if wear app is installed on paired watchAndroid:检查配对手表上是否安装了 Wear 应用程序
【发布时间】:2022-12-15 03:01:38
【问题描述】:

我有两个 Android 应用程序(手机/手表),如果手表上安装了磨损应用程序,我想检查移动应用程序。

有什么想法吗?

我搜索但没有结果。

【问题讨论】:

    标签: android mobile watchkit wear-os


    【解决方案1】:

    Detect your app on another device中有描述,Github中也有示例。

    简而言之,您应该:

    1. 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>
      
      1. 在手机应用程序中,为 CapabilityClient 添加一个侦听器:
              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")
      

    【讨论】:

      猜你喜欢
      • 2014-07-22
      • 2013-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-02
      • 2011-10-14
      相关资源
      最近更新 更多