Running code in main thread from another thread

前端 未结 16 2157
一个人的身影
一个人的身影 2020-11-22 13:50

In an android service I have created thread(s) for doing some background task.

I have a situation where a thread needs to post certain task on main thread\'s message

16条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 14:31

    More precise Kotlin code using handler :

    Handler(Looper.getMainLooper()).post {  
     // your codes here run on main Thread
     }
    

提交回复
热议问题