Reputation: 525
My phone in Huawei g600 and I don't get the temperature sensor in the list of all sensors in my program, but I need the temperature of environment in my application, Does any one has a solution?
List<Sensor> list = sMgr.getSensorList(Sensor.TYPE_PRESSURE);
StringBuilder data = new StringBuilder();
for(Sensor sensor : list){
data.append(sensor.getName() + "\n");
}
sensorslist.setText(data);
Upvotes: 0
Views: 267
Reputation: 843
I appreciate it's an old question but I looked into this too. There is a way you can get a good approximation of the outside temperature, from your battery temperature.
In general the formula:
Te = (m *Tc) + k
works.
For London, for example, m is 2.55 and is dependant on the time of year (summer Vs winter).
Upvotes: 0
Reputation: 93698
Not all (in fact almost none) devices have an external temperature sensor. Its rare hardware and even was discouraged by Google for a while. The reason is that phones run hot- the battery can easily get hot enough to burn. That means any thermometer will be inaccurate. You're better off with either local weather date via web service, or using a usb or bluetooth device connected to your phone to take temperature. Even if you find a device with a temperature sensor you can't trust its accuracy, for the reasons stated above.
Upvotes: 1