2011年5月25日 星期三

Orientation感測器

Orientation感測器
方向感測器
    sensor = sm.getDefaultSensor(Sensor.TYPE_ORIENTATION);
    sm.registerListener(oriSensor, sensor, SensorManager.SENSOR_DELAY_NORMAL);

    // Azimuth : 0=North, 90=East, 180=South, 270=West     private SensorEventListener oriSensor = new SensorEventListener() {
        public void onAccuracyChanged(Sensor sensor, int accuracy) { }

        public void onSensorChanged(SensorEvent event) {
        txtMsg.setText(
            "(Azimuth, Pitch, Roll) = \n" + event.values[0] + "\n" + event.values[1] + "\n" + event.values[2]);
        }
    };

沒有留言:

張貼留言