2013.5.14 Version Control System,Sensor 相关

1,vcs之CVS:concurrent version system

今天要学习一些对我来说是新知识的知识。being happy !

2,Sensor 相关

主要的类有:Sensor ,SensorManager,SensorEvent,SensorEventListener

Sensor :Class representing a sensor. Use getSensorList(int) to get the list of available Sensors.

SensorManager: SensorManager lets you access the device's sensors. Get an instance of this class by calling Context.getSystemService() with the argument SENSOR_SERVICE.

Always make sure to disable sensors you don't need, especially when your activity is paused. Failing to do so can drain the battery in just a few hours. Note that the system will not disable sensors automatically when the screen turns off.

public class SensorActivity extends Activity, implements SensorEventListener {
     private final SensorManager mSensorManager;
     private final Sensor mAccelerometer;

     public SensorActivity() {
         mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
         mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
     }

     protected void onResume() {
         super.onResume();
         mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
     }

     protected void onPause() {
         super.onPause();
         mSensorManager.unregisterListener(this);
     }

     public void onAccuracyChanged(Sensor sensor, int accuracy) {
     }

     public void onSensorChanged(SensorEvent event) {
     }
 }

SensorEvent:  This class represents a  Sensor  event and holds informations such as the sensor's type, the time-stamp, accuracy and of course the sensor's  data .

3,

Android监听HOME按键,利用广播接收者来实现

参考: http://my.eoe.cn/eric_wu/archive/526.html

Intent.ACTION_CLOSE_SYSTEM_DIALOGS
关闭系统dialog的广播,每次点击home键的时候都会发出,一般statusbarservice和系统的recentApplicationDialog有用到。比如statusbar下拉已经展开了,我点了home键,就会自动收回。

当用户按下电源按钮,长按或短按(不管有没跳出话框),进行锁屏时;android系统都会广播此Action消息.


你可能感兴趣的:(2013.5.14 Version Control System,Sensor 相关)