在 Android 中创建自定义硬件传感器
我正在考虑在 Android 中创建自定义传感器,想知道是否有人尝试过这样做。我希望除了使用 Android 开放附件开发套件之外,还有一种方法可以创建自定义传感器。
例如,我制造了一款内置两个水位读取器的定制硬件。有没有办法通过 SensorManager 将它们暴露给 Android 操作系统?以前有人尝试过吗?本质上有一种方法可以将自定义传感器项目添加到 SensorManager。
多谢
I'm looking into creating custom sensors in Android and was wondering if anybody has attempted this. I was hoping there might be a way of creating custom sensors other than by using Android Open Accessory Development Kit.
For example, I manufacture a bespoke piece of hardware which has two water level readers built in. Is there any way of of exposing these to the Android OS via the SensorManager? Has anyone attempted this before? Essentially is there a way of adding custom Sensor items to the SensorManager.
Thanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想说的是,不可能修改传感器管理器提供的传感器集 - 它是具有硬编码的传感器类型集的系统服务。
如果您提供 Android 服务 而不是提供这些服务,这可能是最好的传感器读数然后可供任何需要它们的应用程序使用。
该服务可能会包装附件 devkit api 以实际与您的设备进行通信。
您将从中派生的服务基类是这样的,其中包括示例:
I would say that it's not possible to modify the set of sensors provided by the sensor manager - it's a system service with a hard coded set of sensor types.
It would probably be best if you provided an Android service instead which provided these sensor readings which would then be available to any app which needed them.
This service would probably wrap the accessory devkit api to actually communicate with your device.
The service base class you would derive from would be this, which includes examples:
我对此没有经验,但我最近读了一些类似主题的书。
我假设您已经了解 Arduino。我可以提供一个项目的链接,作者从一些外部传感器获取信息,并通过 Android 设备进行控制。我认为这个项目 与您想要做的类似。
I have no experience on this, but I did some reading on similar topics recently.
I assume you already know about Arduino. I can give a link to a project where the author gets information from some external sensors and the control is done from an Android device. I consider that this project is similar to what you want to do.