简体   繁体   English

从 Wear 应用程序检查 Wear 设备是否已连接到手持设备,2021

[英]From Wear app check if Wear device is connected to Handheld device, 2021

From a Wear app I'm trying to constantly check if the Wear device is connected to the Handheld device.从 Wear 应用程序中,我试图不断检查 Wear 设备是否已连接到手持设备。 We can do that through Wearable.getNodeClient(context).connectedNodes .我们可以通过Wearable.getNodeClient(context).connectedNodes做到这一点。 Is there any way to add a listener to that data?有没有办法为该数据添加一个监听器? Also, is there any way to make sure any of these nodes is a Handheld device?另外,有没有办法确保这些节点中的任何一个都是手持设备?

Using the CapabilityClient we can know if the app is installed by adding a capability to the wear.xml file in the Handheld app.使用 CapabilityClient,我们可以通过在 Handheld 应用程序中的wear.xml文件中添加功能来了解应用程序是否已安装。 I am not looking to check that.我不打算检查。

I've also seen this question, but it doesn't answer mine.我也看过这个问题,但它没有回答我的问题。

Yes, you can add an ACTION_CAPABILITY_CHANGED action to the manifest and then add a CapabilityClient listener.是的,您可以将ACTION_CAPABILITY_CHANGED操作添加到清单,然后添加CapabilityClient侦听器。 Within your OnCapabilityChangedListener you can then check getNodes() from the passed in CapabilityInfo to obtain an updated list of available modes.在您的OnCapabilityChangedListener ,您可以从传入的CapabilityInfo检查 getNodes getNodes()以获得可用模式的更新列表。 As for checking if it's a handheld or a watch, you should already have different capability strings for each, so you can simply filter the node set on the one you've set for the handheld.至于检查它是手持设备还是手表,您应该已经为每个设备设置了不同的功能字符串,因此您可以简单地过滤您为手持设备设置的节点集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 识别穿戴设备上特定手持式应用的通知 - Recognize notifications from particular handheld app on wear device Android Wear(手表)。 有没有办法检测磨损是否与任何设备相连,仅仅是磨损? - Android Wear(Watch). Is there any way to detect that wear is connected to any device or not, from the wear only? 从Real Device卸载Android Wear应用程序 - Uninstall Android Wear App From Real Device Android手机应用未在连接的Android Wear设备中安装该应用 - Android phone app is not installing the app in the connected android wear device Android Wear如何使手持式wifi设备保持激活状态? - How an Android Wear can keep the handheld wifi device activated? 如何将多个Android磨损模拟器连接到手持设备? - How to connect multiple android wear emulators to a handheld device? 无法在Wear设备上启动嵌入式Wear App的活动 - Unable to start activity of embedded Wear App, on Wear device 从Companion Mobile App从环境模式唤醒穿戴设备 - Waking Wear Device from Ambient Mode from Companion Mobile App 当应用未运行时,从Android主机设备发送消息以穿戴 - Sending message from Android host device to wear when app is not running Android Wear Preview应用与我的设备不兼容 - Android Wear Preview app is incompatible with my device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM