MainActivity.kt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
package com.example.myapplication import android.hardware.Sensor import android.hardware.SensorManager import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.layout.Column import androidx.compose.material3.Text import androidx.compose.runtime.Composable class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { val sensorManager = getSystemService(SENSOR_SERVICE) as SensorManager val listaSensores: List<Sensor> = sensorManager.getSensorList(Sensor.TYPE_ALL) SensorList(sensors = listaSensores) } } } @Composable fun SensorList(sensors: List<Sensor>) { Column { sensors.forEach { sensor -> Text(text = sensor.name) } } } |