Closed Productivix closed 3 years ago
rather :
class MainActivity : AppCompatActivity() {
private var mSensorManager: SensorManager? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
mSensorManager = this.getSystemService(SENSOR_SERVICE) as SensorManager?
val sensorList: List
}
after debug it is :
class MainActivity : AppCompatActivity() {
private var mSensorManager: SensorManager? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
mSensorManager = this.getSystemService(SENSOR_SERVICE) as SensorManager?
val sensorList = mSensorManager?.getSensorList(Sensor.TYPE_ALL)
val sensorText = StringBuilder()
if (sensorList != null) {
for (currentSensor in sensorList) {
sensorText.append(currentSensor.name).append(
System.getProperty("line.separator"))
}
}
val sensorTextView = findViewById
}
Describe the problem A clear and concise description of what the problem is. it seem to be written in Java and when you copy it in android studio, it converts it in Kotlin , with more or less success
In which lesson and step of the codelab can this issue be found? Lesson number + step number. (e.g., Lesson 1.1, Step 1.3) : Advanced Android 03.1: Getting sensor data
How to reproduce? What are the exact steps to reproduce the problem? just copy your code
Versions
Additional information Add any other context about the problem here.
codelab: advanced-android
The best code I add is : class MainActivity : AppCompatActivity() { private var mSensorManager: SensorManager? = null