是否有任何Android的API来获取/检测室温编程方式在android的code?室温、有任何、方式、Android

2023-09-06 13:39:02 作者:劈腿的年代谁还TM相信真爱

我开发我的项目一个Android应用程序,我需要找到室温作为它的一部分。我使用的Droid 2 A955模型进行测试。

I am developing an android app for my project, I need to find room temperature as part of it. I am using Droid 2 A955 model for testing.

我的问题是:

什么传感器需要可在我的Andr​​oid手机来执行 这个温度传感任务?

What sensors need to be available in my Android phone to perform this temperature sensing task?

可环境光传感器,这样做帮助(在Droid 2的提供) 任务是什么?

Can Ambient Light Sensor (available in Droid 2) help in doing this task?

有没有Android的API来查找/感室温 以编程方式在我的Andr​​oid code?

Is there any Android api to find/sense room temperature programmatically in my android code?

在此先感谢您的帮助。

推荐答案

要回答这三个你的问题一举,不,我不这么认为。可以存在在机器人设备的温度传感器,但它检测的电池,不外界温度的温度。它不会提供准确的测量仪用于该目的。

To answer all three of your questions in one fell swoop, no, I don't believe so. There can be a temperature sensor in android devices, but it senses the temperature of the battery, not the outside temperature. It would not provide an accurate gauge for that purpose.

我不知道如何将环境光传感器将帮助下,它可以是非常光明的了,但它可以在有空调的房间里。

I'm not sure how an ambient light sensor would help with temperature, it can be very bright out but it could be in an air conditioned room.

最后:有许多温度的应用程序的例子,但是,大多数都涉及到电池

Lastly: there are lots of examples of temperature apps, but again, most are related to the battery.

编辑: 官方文件说:

设备实现可能,但不应包括温度计(即温度传感器。)如果设备实现不包括 温度计,它必须测量设备CPU的温度。它不能测量任何其他温度。 (请注意,此传感器类型是 德precated在Android 2.3的API。)

Device implementations MAY but SHOULD NOT include a thermometer (i.e. temperature sensor.) If a device implementation does include a thermometer, it MUST measure the temperature of the device CPU. It MUST NOT measure any other temperature. (Note that this sensor type is deprecated in the Android 2.3 APIs.)

更新:

API级14(也就是Android 4.0的)开始,测量环境温度支持已被添加(通过 TYPE_AMBIENT_TEMPERATURE )。 [Android的文档参考]

API level 14 (i.e. Android 4.0) onwards, support for measuring ambient temperature has been added (via TYPE_AMBIENT_TEMPERATURE). [Android doc reference]

此,但是,将只在与环境温度传感器设备一起工作。

This, however, will work only on devices with ambient temperature sensor.