So, I am aware of the fact that in Android, views cannot be updated from a background thread.
I have a TextView called appTitle.
I am launching a coroutine on background thread ( IO ) and on that background thread, I am updating the title of TextView.
Technically that code should fail. But it is not raising any exceptions and is working fine. I am curious as to why this thing is not raising any exceptions like : CalledFromWrongThreadException
P.S TO make the matter even worse, I am constantly updating the title every half second, not to miss any special case that would otherwise arise due to how render cycles work.
CoroutineScope(Dispatchers.IO).launch{
Log.d(TAG, "onCreate Current thread name: ${Thread.currentThread().name}")
val arr = arrayOf(appTitle.text.toString(),"Modified App Title")
var index = 0;
for (i in 1..100){
appTitle.text =arr[index]
delay(500)
if(index==0)index=1
else index =0
}
}
appTitle?