In my Android application I have a simple case where I periodically poll for a new value and then run a RoomDB Query which updates the value in the database.
fun updateStatus(
sensorId: String,
state: String,
) {
scope.launch {
db.statusDao().setLastState(sensorId, state)
}
}
... and ...
infoTimer = Timer()
infoTimer.scheduleAtFixedRate(
object : TimerTask() {
override fun run() {
... in the end updateStatus() is called
}
},
0,
300,
)
I noticed that while this is happening the CPU is constantly rising. Shorter the timeout the steeper it goes.
Any ideas what is causing this and how to stop it from happening?
