# android

Chris Fillmore

09/28/2020, 7:01 PM
Hi folks, I’m curious if there is any point to using thread annotations with Kotlin, assuming you are not managing any threads directly, and just using coroutines? My use case is: I have a third-party library which throws an exception if certain methods are not run on the main thread. I would like to annotate these methods in a thin wrapper so that Android Studio will generate a warning. But I don’t see how to do this; when I annotate the methods and launch from e.g. Dispatchers.IO, I don’t get a warning


09/28/2020, 11:25 PM
If you use coroutines it's better to switch thread instead of annotating, so it would be transparent for user of this api, but of course it means that method becomes suspend one I believe support of thread annotations is a part of Android Plugin and it pretty limited (I mean detection of incorrect usage), I would report it to Android issue tracker to support at least case when call wrapped to dispatchers