In order to conserve device power, applications should choose the slowest accelerometer update rate possible to achieve the desired result. Values available for setting the update rate are defined in android.hardware.SensorManager
and are listed below in order of decreasing update rate.
Constant Name | Relative Speed |
---|---|
SENSOR_DELAY_FASTEST
|
fastest |
SENSOR_DELAY_GAME
|
faster |
SENSOR_DELAY_NORMAL
|
slower |
SENSOR_DELAY_UI
|
slowest |
A sample of setting the sensor update rate is shown below.
if (mSensorManager == null) mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE); if (mSensorManager != null) mSensorManager.registerListener( this, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SENSOR_DELAY_GAME );
Note that the 'delay' values are abstract, with values specific to a given device, and thus rates could vary significantly between different devices. The only way to guarantee a certain update rate is to measure the rate returned by a device at run time.
NVIDIA® GameWorks™ Documentation Rev. 1.0.211026 ©2014-2021. NVIDIA Corporation and affiliates. All Rights Reserved.