Created
April 21, 2015 12:04
-
-
Save defHLT/5d54a354198534e8377a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Sensor getDefaultSensor() { | |
Sensor gravitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY); | |
Sensor accelSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); | |
if (gravitySensor != null) | |
return gravitySensor; | |
else if (accelSensor != null) | |
return accelSensor; | |
else { | |
throw new RuntimeException("It seems device has neither gravity nor accelerometer sensor"); | |
} | |
} |
Author
defHLT
commented
Apr 21, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment