android - calling ui thread from worker thread

后端 未结 7 2207
再見小時候
再見小時候 2020-12-11 00:12

Hi I want to make Toast available to me no-matter-what and available from any thread whenever I like within my application. So to do this I extended the A

7条回答
  •  感情败类
    2020-12-11 01:01

    if you have the context with you, you can call the ui thread like this from non activity class.

    ((Activity)context).runOnUiThread(new Runnable() {
        public void run() {
            // things need to work on ui thread
        }
    });
    

提交回复
热议问题