I have created a proximity service which performs basic on/off of screen depending on the sensor value. I needed to time these sensor changes so i used the following code
override fun onSensorChanged(event: SensorEvent) {
val distance = event.values[0]
val max = event.sensor.maximumRange
val startTime = System.currentTimeMillis()
if (distance < Math.min(max, 8.toFloat())) {
listener.onNear()
} else {
listener.onFar()
}
val endTime = System.currentTimeMillis()
System.out.println("That took " + (endTime - startTime) + " milliseconds")
}
I am getting the values in log cat but i need to print these on my app, my app activity is in another java class called settings activity. I have added a textview called "Time taken" how to push those values of (endTime-startTime) to this textview??? or should i have to use any other layout comonent?? My settings layout image