How do we use runOnUiThread in Android?
Below is corrected Snippet of runThread Function.
Below is corrected Snippet of runThread Function.
You’re calling it from a worker thread. You need to call Toast.makeText() (and most other functions dealing with the UI) from within the main thread. You could use a handler, for example. Look up Communicating with the UI Thread in the documentation. In a nutshell: Other options: You could use Activity.runOnUiThread(). Straightforward if you have an Activity: You could also post … Read more
You’re calling it from a worker thread. You need to call Toast.makeText() (and most other functions dealing with the UI) from within the main thread. You could use a handler, for example. Look up Communicating with the UI Thread in the documentation. In a nutshell: Other options: You could use Activity.runOnUiThread(). Straightforward if you have an Activity: You could also post … Read more