如何获得在Android的电池温度 [英] how to get battery temperature in android

查看:1339
本文介绍了如何获得在Android的电池温度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  获取电池在Android 温度

Possible Duplicate:
Get temperature of battery on android

你好

我想获得电池温度的机器人。我怎样才能达到同样的?是否有任何API可用?请大家帮帮忙。

I want to get battery temperature in android. How can i achieve the same? Is there any api available? Please help.

推荐答案

您可以找到<一href="http://www.tutorialforandroid.com/2009/01/getting-battery-information-on-android.html">here如何登记更换电池。使用额外的价值( EXTRA_TEMPERATURE ),你可以得到的温度。

You can find here how to register to battery changes. Using the extra value (EXTRA_TEMPERATURE) you can get the temperature.

在短(取自上面的链接,并修改了一下):

In short (taken from the link above and modified a bit):

声明广播接收器:

private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver(){
    @Override
    public void onReceive(Context arg0, Intent intent) {
      int temperature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0);
      ....
    }
  };

的onCreate ,地址:

this.registerReceiver(this.mBatInfoReceiver, 
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

这篇关于如何获得在Android的电池温度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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