android - calling ui thread from worker thread

后端 未结 7 2239
再見小時候
再見小時候 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:00

    use below code. create activity object which contains your activity instance..

    activity.runOnUiThread(new Runnable() {
      public void run() {
        Toast.makeText(activity.getApplicationContext(),"Toast text",Toast.LENGTH_SHORT).show();
      }
    );
    

提交回复
热议问题