Skip to content

Instantly share code, notes, and snippets.

@Lavanyagaur22
Last active January 17, 2020 05:49
Show Gist options
  • Save Lavanyagaur22/aca253b30d841444d6ae34475a0c2d8d to your computer and use it in GitHub Desktop.
Save Lavanyagaur22/aca253b30d841444d6ae34475a0c2d8d to your computer and use it in GitHub Desktop.
//To get a list of all sensors present on the device.
val deviceSensors: List<Sensor> = sensorManager.getSensorList(Sensor.TYPE_ALL)
//To get the default gravity sensor present on the device
val gravSensor = sensorManager.getDefaultSensor(TYPE_GRAVITY)
//To check the power of the sensor if present
val power = gravSensor.getPower()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment