I have this code executed in Kotlin
android project and it will log both messages. If I change the token
to Char
or String
it will print only one message which is the wanted behaviour. Same use-case in a java project in android works as it should.
val handler = Handler()
//val token1: Long = 1001L
//val token2: Int = 121
val token1: Long = 1001L
val token2: Int = 1002
handler.postAtTime(
{
Log.e("postAtTime 1", " printed 1 ")
handler.removeCallbacksAndMessages(token2)
},
token1,
SystemClock.uptimeMillis() + 2000
)
handler.postAtTime(
{
Log.e("postAtTime 2", " printed 2 ")
},
token2,
SystemClock.uptimeMillis() + 4000
)
My question is why in Kotlin for a token of type Int
, Long
the handler doesnt remove the callback?
EDIT If I try with commented values it works
from Android Handler callback not removed for token type Int or Long (*Kotlin)
No comments:
Post a Comment