如何在不使用ControlExtension的情况下使用Sensor API? [英] How to use Sensor API without ControlExtension?

查看:100
本文介绍了如何在不使用ControlExtension的情况下使用Sensor API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为Smartwatch 2创建一个应用程序,该应用程序可以监听手表的加速度传感器并将其值发送到在手机上运行的另一个应用程序.基本上,无论用户是否使用手表,它总是在听加速度计.因此,我想只使用ExtensionService,将来可能会使用Notification API来基于加速度计发送监视警报.

I am trying to make an app for the Smartwatch 2 that listens to the watch's accelerometer sensor and sends the values to another app running on the phone. Basically, its always listening to the accelerometer, whether the user is using the watch or not. As such, I'd like to do this using only the ExtensionService, and possibly the Notification API in the future to send the watch alerts based on the accelerometer.

问题是,我无法弄清楚如何在没有ControlExtension的情况下正确添加和监听传感器(如SampleSensorExtension中所示).

The problem is, I can't figure out how to properly add and listen to the Sensors without a ControlExtension (as in the SampleSensorExtension).

问题似乎是无法在ControlExtension之外向AccessorySensorManager添加传感器.如果我尝试在onCreate(),onStartCommand()或什至onRegisterResult()方法中执行此操作,则找不到任何可用的传感器.因此,DeviceInfoHelper.isSensorSupported(this,this.getPackageName(),SensorTypeValue.))始终返回false.

The problems seems to be that there is no way to add sensors to the AccessorySensorManager outside of the ControlExtension. If I try to do this in the onCreate(), onStartCommand() or even the onRegisterResult() methods, I can't find any available sensors. As such, DeviceInfoHelper.isSensorSupported(this, this.getPackageName(), SensorTypeValue.)) always returns false.

如何在ExtensionService中获取和添加所有受支持的传感器?索尼工程师能否请您介绍一下情况并考虑可能的解决方案?谢谢!

How to get and add all supported sensors within the ExtensionService? Can a Sony Engineer please shed some light on the situation and consider a potential solution? Thanks!

推荐答案

在不使用Control API的情况下也无法使用Sensor API.如果您使用的是Control Extension,则可以在手表进入低功耗模式时捕获加速度计数据.

It is not possible to use the Sensor API without using the Control API as well. If you are using a Control extension it is possible to capture accelerometer data when the watch goes into low power mode as you know already.

这篇关于如何在不使用ControlExtension的情况下使用Sensor API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆