标签:style sp for on log bs cti as size
类extends Activity implements SensorEventListener
@Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
if(event.sensor.getType()==Sensor.TYPE_TEMPERATURE){
Log.e("Log", "temprature==="+event.values[0]);
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
传感器
private SensorManager mSensorManager;
用于判断是否注册成功
boolean mRegisteredSensor;
protected void onResume() {
super.onResume();
mSensorManager=(SensorManager)getSystemService(SENSOR_SERVICE);
List<Sensor> sensors=mSensorManager.getSensorList(Sensor.TYPE_ALL);//获得一个方向传感器
for (Sensor s : sensors) {
Log.e("Log", "sensors.name==="+s.getType());
}
if (sensors.size()>0)
{
Sensor sensor=sensors.get(0);
mRegisteredSensor=mSensorManager.registerListener(this,sensor,SensorManager.SENSOR_DELAY_FASTEST);
Log.e("Log", "booelan =="+mRegisteredSensor);
}
}
protected void onPause()
{
if (mRegisteredSensor) {
mSensorManager.unregisterListener(this);
mRegisteredSensor=false;
}
super.onPause();
}
标签:style sp for on log bs cti as size
原文地址:http://blog.csdn.net/limingnanhai/article/details/41679675