Accessing UI thread handler from a service

后端 未结 7 1528
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 11:57

I am trying some thing new on Android for which I need to access the handler of the UI thread.

I know the following:

  1. The UI thread has its own handler
7条回答
  •  春和景丽
    2020-11-27 12:40

    I suggest trying following code:

        new Handler(Looper.getMainLooper()).post(() -> {
    
            //UI THREAD CODE HERE
    
    
    
        });
    

提交回复
热议问题