Cannot use vibration in a Thread
I'm trying to use the vibrator service inside a Thread class but when I do so, I have an error which says "Type mismatch: inferred type is String but Context was expected"
here is my code :
class myThread: Thread() {
override fun run() {
var vibration = getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
for(i in 1..5) {
vibration.vibrate(100)
Thread.sleep(1000)
}
}
}
It works in my mainActivity class but it doesn't in a Thread....