Questions tagged [android-runonuithread]

This is a way to run the specified action on the UI thread of Android framework.

runOnUIThread is a method of an Android's Activity:
It runs the specified action on the UI thread. If the current thread is the UI thread, then the action is executed immediately. If the current thread is not the UI thread, the action is posted to the event queue of the UI thread.

Useful links

187 questions
0
votes
1 answer

runOnUiThread() not executed

I would like to manipulate my UI through this runOnUiThread(). doStuff can be executed when I delete everything in it except the Speech output. But when I leave it like that nothing in doStuff is executed. Any idea why nothing happens? public void…
phsycholic
  • 33
  • 2
0
votes
1 answer

ArrayAdapter notifyDataSetChanged not being executed on UI thread

I am running the below code inside a new thread that I create by doing: new Thread(new Runnable() { public void run() { // CODE BELOW } }).start(); So my runonUI code is never being executed. I am under the impression that I need to…
0
votes
1 answer

Thread doesn't execute a Dialog?

I have a Dialog and a Thread. When thread finished I want to execute the Dialog. The problem is sometimes execute and sometimes does not. I can not understand why this happens. How can I solve it ? /** display dialog */ private void showDialog(int…
FernandoPaiva
  • 4,410
  • 13
  • 59
  • 118
0
votes
1 answer

Unable to update seekbar with Handler

I am trying to update seekbar with respect to the progress of the song in MediaPlayer. I am using Thread to do that task. First i have used Thred inside thread and trying to update the UI but it crashing the app and says that only original thread…
Shreyash Mahajan
  • 23,386
  • 35
  • 116
  • 188
0
votes
1 answer

how to re-start a thread?

I have two threads, one of them starts when i press a button. it just display values from 1-20 on the button btn.settext(""+ j). inside the listener fo that button I wrote the following: btn_listener.setOnClickLstener(new Listener) { public void…
rmaik
  • 1,076
  • 3
  • 15
  • 48
0
votes
3 answers

setListAdapter not displaying

I am trying to display set of fetch results as a list. Whenever I try to use dummy data, it's displayed correctly but when I change it to the data retrieved from the server nothing happens. I do not get any errors so that's very confusing import…
omarsafwany
  • 3,695
  • 8
  • 44
  • 75
0
votes
1 answer

Call Thread.wait()

I need to make currentThread wait when do some operations in UiThread and then in UiThread call currentThread().notify() . I was trying this code Handler uiHandler = new Handler(Looper.getMainLooper()); uiHandler.post(new Runnable() { …
-1
votes
1 answer

Android runOnUiThread() thread is fluctuating

In Android app, I am using NFC reader. There is a listener for that NFC reader in the app. When an NFC tag is read, it triggers the listener in the app. That listener is not in the main thread, but a worker thread. When that event is called, I need…
Atul Kumar
  • 549
  • 1
  • 6
  • 12
-1
votes
2 answers

runOnUiThread doesn't work in Android

I see Here3 and Here4 True True on logcat but commands(alertdialog, mediaPlayerStop and VibrateStop) doesn't work in run() method. Any suggestion? Thanks in advance. if(check == 1) { Log.i("XXX", "Here3"); runOnUiThread(new…
ozo
  • 101
  • 1
  • 2
  • 13
-1
votes
2 answers

Okhttp3 making app crash on closing the activity before the request loads

Everything works fine. But I'm loading the Question Fragment and immediately clicking back and exiting the app without letting the request to be completed. It crashes the app. I tried looking around but can't find a fix that will help me prevent the…
Harman Kamboj
  • 429
  • 7
  • 20
-1
votes
1 answer

sometimes a field annotated with @ViewById returns null when accessed on UIThread

I have a class which uses AndroidAnnotations and @ViewById annotation. I've seen many crashes because of some of the fields with @ViewById annotations being null. Attempt to invoke virtual method 'void…
-1
votes
2 answers

App hangs while doing fragment transaction in runOnUiThread

In my app, I'm doing a network operation in a thread. In the result of the network operation, I show a toast and replace the fragment using the runOnUiThread() method. But the app gets hanged after the fragment is replaced. Here is my…
Madhan
  • 555
  • 5
  • 23
-1
votes
2 answers

runOnUiThread settext only works at the first time during a loop

I have an ArrayList of Textviews populated by an expandListAdpater, my goal is to change the values of the textViews, but for some reason it works only once. I tried different timers, tried to tie my handler to the ui thread, it never works. here is…
-1
votes
3 answers

android.os.NetworkOnMainThreadException when trying to use a service

I'm trying to build an app that constantly reads SBS-1 data from a server running dump1090. I thought I'd be better off using a Service rather than an AsyncTask to do so, as at least its lifecycle would be independent of UI components, plus AFAIK…
-1
votes
1 answer

Getting java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

I am trying to call AsyncTask from runonUiThread like below MutiThreadActivity.this.runOnUiThread(new Runnable() { public void run() { Toast.makeText(MutiThreadActivity.this, "This is Toast!!!", Toast.LENGTH_SHORT).show(); new…
Pinki
  • 21,723
  • 16
  • 55
  • 88
1 2 3
12
13