Skip to content

Instantly share code, notes, and snippets.

@Younes-Charfaoui
Created August 3, 2020 10:11
Show Gist options
  • Save Younes-Charfaoui/d204a7987c75b1971fa7e4b77d99ff4e to your computer and use it in GitHub Desktop.
Save Younes-Charfaoui/d204a7987c75b1971fa7e4b77d99ff4e to your computer and use it in GitHub Desktop.
private lateinit var sensorManager: SensorManager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// initializing the sensor manager
sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager
// getting the list of all the availabale sensors in the current device
val deviceSensors: List<Sensor> = sensorManager.getSensorList(Sensor.TYPE_ALL)
deviceSensors.forEach { sensor ->
Log.d("SENSORS", "Sensor Name: ${sensor.name}")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment