2012-04-06 151 views
7

有沒有人可以告訴我Android傳感器中的SENSOR_DELAY_NORMAL,SENSOR_DELAY_GAME,SENSOR_DELAY_UISENSOR_DELAY_FASTEST之間有什麼區別。Android:傳感器

開發人員應該在哪裏使用所有這些東西?用戶使用所有這些會有什麼感受?

回答

5

INT SENSOR_DELAY_FASTEST獲得傳感器數據一樣快,適合遊戲 INT SENSOR_DELAY_NORMAL率(默認)適用於屏幕方向的變化是基於一些近似適合用戶界面

+0

謝謝您的回答。我有一個應用程序讀取傳感器值與上述所有選項。 SENSOR_DELAY_FASTEST和SENSOR_DELAY_NORMAL之間沒有差異值。 – Prasad 2012-04-06 13:49:45

+1

我會認爲差異會在時間,而不是價值... – Barak 2012-04-06 13:54:20

+0

是@Barak是正確的。差別在於時間。傳感器多久進行一次輪詢。 – jsb 2012-04-06 14:01:02

18

這裏 INT SENSOR_DELAY_UI率可能 INT SENSOR_DELAY_GAME率上測試的結果:

Accelerometer, SENSOR_DELAY_FASTEST: 18-20 ms 
Accelerometer, SENSOR_DELAY_GAME: 37-39 ms 
Accelerometer, SENSOR_DELAY_UI: 85-87 ms 
Accelerometer, SENSOR_DELAY_NORMAL: 215-230 ms 
Orientation Sensor, SENSOR_DELAY_FASTEST: 16-17 ms 
Orientation Sensor, SENSOR_DELAY_GAME: 37-39 ms 
Orientation Sensor, SENSOR_DELAY_UI: 77 ms 
Orientation Sensor, SENSOR_DELAY_NORMAL: 224-225 ms 

您也可以定義自己的速度,例如100ms。在我們

INT READINGRATE = 100000%時間 mSensorManager.registerListener(此,mLinearAccelerometer, READINGRATE);

但是,速率只是一個近似值,如果您需要準確的速率,最好使用定時器。

0

我的結果與設備:
榮譽4C Andro ID 5.1.1
的Xperia Z3的Android 6.0.1
Sensor.TYPE_ACCELEROMETER

Approximate values: 

For samplingPeriodUs: 0ms: 
Honor: 4-12ms, long time(1min) 10ms 
Xperia: 1-5ms, long time(1min) 3ms 

For samplingPeriodUs: 30ms: 
Honor: 4-12ms, long time(1min) 7ms 
Xperia: 7-21ms, long time(1min) 20ms 

For samplingPeriodUs: SensorManager.SENSOR_DELAY_NORMAL: 
Many tests from internet: Accelerometer, SENSOR_DELAY_NORMAL: 215-230 ms 
Honor: 4-11ms, long time(1min) 10ms 
Xperia: 6-114ms, long time(1min) 14ms 

Omitted:SENSOR_DELAY_GAME, SENSOR_DELAY_UI 

For samplingPeriodUs: SensorManager.SENSOR_DELAY_FASTEST: 
Many tests from internet: Accelerometer, SENSOR_DELAY_FASTEST: 18-20 ms 
Honor: 3-12ms, long time(1min) 8ms 
Xperia: 1-5ms, long time(1min) 5ms