Sensor Type:
Direction, acceleration (gravity), light, magnetic field, distance (closeness), temperature, etc.
(1), direction sensor: sensor. type_orientation
(2) g_sensor acceleration (gravity) sensor: sensor. type_accelerometer
(3) Rochelle sensor light sensor: sensor. type_light
(4) m_sensor Magnetic Field Sensor: sensor. type_magnetic_field
(5), p_sensor distance (proximity) sensor: sensor. type_proximity
(6) Temperature Sensor: sensor. type_temperature
ProgramApplication in:
// Obtain a sensor type
Sensor sensor = sensormanager. getdefasensensor (sensor. type_accelerometer );
// Register the listener to obtain the sensor change value
Sensormanager. registerlistener (listener, sensor, sensormanager. sensor_delay_game );
The third parameter above is the sampling rate: the fastest, game, normal, and user interface.
When an application requests a specific sampling rate, it is only a recommendation for the sensor subsystem, and the specific sampling rate is not guaranteed to be available.
Fastest: sensormanager. sensor_delay_fastest
The lowest latency is generally not recommended for processing especially sensitive data. This mode may cause a large amount of power consumption on mobile phones,AlgorithmPoor processing will affect the game logic and UI performance.
Game: sensormanager. sensor_delay_game
Game latency. This level is generally used in most real-time games.
Normal: sensormanager. sensor_delay_normal
Standard latency can be used for general games of the benefit or easy level, but a low sampling rate may cause frame skipping for some racing games.
User Interface: sensormanager. sensor_delay_ui
It is generally used for automatic screen rotation, which saves power and logic processing, but is not used in game development.