You can do it by calling an Activity
‘s runOnUiThread
method from your thread:
activity.runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(activity, "Hello", Toast.LENGTH_SHORT).show();
}
});
More Related Contents:
- How to stop the thread in android activity [duplicate]
- Can’t create handler inside thread that has not called Looper.prepare()
- Android “Only the original thread that created a view hierarchy can touch its views.”
- The application may be doing too much work on its main thread
- How to run a Runnable thread in Android at defined intervals?
- Handler vs AsyncTask vs Thread [closed]
- Update UI from Thread in Android
- Service vs IntentService in the Android platform
- Android AsyncTask threads limits?
- Best practice: AsyncTask during orientation change
- AsyncTask threads never die
- How to pause/resume thread in Android?
- How can I run code on a background thread on Android?
- How to stop a thread?
- Accessing UI thread handler from a service
- Threading Example in Android [closed]
- Android how to runOnUiThread in other class?
- Start a service in a separate process android
- Technical details of Android Garbage Collector
- Okhttp response callbacks on the main thread
- Why to use Handlers while runOnUiThread does the same?
- Application threads vs Service threads
- Is it possible to use AsyncTask in a Service class?
- onPostExecute on cancelled AsyncTask
- AsyncTask as kotlin coroutine
- how to pause and resume a surfaceView thread
- Android – Run a thread repeatingly within a timer
- Posting Toast message from a Thread
- Android: RunOnUiThread vs AsyncTask
- Android Process Scheduling