Running code on the main thread from a secondary thread?

前端 未结 5 545
灰色年华
灰色年华 2020-12-05 10:23

This is a general Java question and not an Android one first off!

I\'d like to know how to run code on the main thread, from the context of a secondary thread. For e

5条回答
  •  心在旅途
    2020-12-05 11:01

    In case you are on Android, using a Handler should do the job?

    new Handler(Looper.getMainLooper()).post(new Runnable () {
        @Override
        public void run () {
            ...
        }
    });
    

提交回复
热议问题