Difference between android runOnUiThread and simple code in java

后端 未结 3 847
栀梦
栀梦 2021-02-06 04:33

I am a beginner in android application development.I am working with threads in android.I have read about a runOnUiThread which run code on main UI(if i am not wron

3条回答
  •  遥遥无期
    2021-02-06 04:56

    Normally your code is executed on your UI thread. For longer taking tasks (such as network requests, etc...) you will use a background tasks (Handler, AsyncTask, Thread, ...).

    As your Views can only be touched from a UI thread, you use runOnUiThread() if you are executing code in a background thread and you need to update your views, from this background thread.

提交回复
热议问题