android - Barometric pressure - not getting values -
i've read environment sensors documentation i'm trying pressure
, unsuccessfully.
this have:
public class pressure extends activity implements sensoreventlistener{ textview textview; private sensormanager sensormanager; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.my_pressure); textview = (textview) findviewbyid(r.id.txt_pressure); sensormanager = (sensormanager) getsystemservice(service.sensor_service); } @override protected void onresume() { super.onresume(); sensormanager.registerlistener(this, sensormanager.getdefaultsensor(sensor.type_pressure), sensormanager.sensor_delay_normal); } @override public void onsensorchanged(sensorevent event) { if (event.sensor.gettype() == sensor.type_pressure) { float[] values = event.values; textview.settext("" + values[0]); } } @override public void onaccuracychanged(sensor sensor, int accuracy) { } @override protected void onpause() { super.onpause(); sensormanager.unregisterlistener(this); }
Comments
Post a Comment