第一頁 返回 繼續 最後一頁 概覽 圖形
Sensors(1)
Sensor Services are System Services
SensorManager SM = (SensorManager) getSystemService(SENSOR_SERVICE);
Register Sensor Event Listener
List sensors = SM.getSensorList(Sensor.TYPE_ALL);
int i;Sensor sn;
for (i=0;i<sensors.size();i++)
{sn=(Sensor) sensors.get(i);
if (sn.getType()==Sensor.TYPE_ACCELEROMETER)
{ SM.registerListener(this, (Sensor) sensors.get(i), SensorManager.SENSOR_DELAY_GAME);
//SENSOR_DELAY_NORMAL SENSOR_DELAY_GAME SENSOR_DELAY_FASTEST SENSOR_DELAY_UI SENSOR_DELAY_GAME
}
}