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
2 answers

How to stop the thread in Android?

I have a thread in my callback function as follows: @Override public void onConnectError(final BluetoothDevice device, String message) { Log.d("TAG","Trying again in 3 sec."); runOnUiThread(new Runnable() { @Override public…
John
  • 2,838
  • 7
  • 36
  • 65
0
votes
1 answer

Updating a view from RunOnUIThread works until activity is restarted

I'm updating a textView with it's setText method in a RunOnUIThread Runnable in the onPostExecute method of an AsyncTask. The first time I run the activity, the textView updates. However when I go to another activity and return to the previous…
0
votes
0 answers

UI elements does not update when they should

I have a download service which updates the UI trough callbacks. For an example if I cancel a downloading task, than the UI at the correct item should change accordingly. The UI update method looks like this: activity.runOnUiThread(new Runnable()…
parohy
  • 2,070
  • 2
  • 22
  • 38
0
votes
2 answers

How can I display a view without waiting for the rest of the UI thread to finish?

Basically I have a popup window that I am trying to launch and have open while the rest of my UI loads(it's some canvas calls that take a second or two), but the behavior I'm getting is that the popup window doesn't display until everything has…
jagrakye
  • 357
  • 1
  • 2
  • 11
0
votes
3 answers

Android Timer Task Issue

I need a timer when Loaded ListView . Like " Waiting [(Timer) 42] Seconds for buy elements " I want to show users Textview Like it. I can't use Thread in ListView... I get Error from runOnUiThread. Why ? I cant use timer In Listview. @Override …
Somomo1q
  • 655
  • 2
  • 10
  • 19
0
votes
1 answer

hide / show action bar in fragment

I have MainActivity extends AppCompatActivity. In that 3 fragments which can be changed by sliding gesture. I want to remove action bar in middle one. And Add action bar again when user slide in 1st or 3rd fragment. I have below…
RNK
  • 5,582
  • 11
  • 65
  • 133
0
votes
0 answers

Android runOnUiThread not displaying

So I have a problem with an Android App I'm giving maintenance they have a callBack on the app that is trigger when something happens, and there is a runOnUiThread. However it seems not to be working but. When I minimize the app and I resume it...…
VidalRmrz
  • 27
  • 7
0
votes
2 answers

How to show Toast messages from a thread in another class

I'm developing an app and I need to show a Toast message from a Thread that runs in another class. I Read about runOnUiThread but it doesn't works.. In main activty there is a call to another java class and here there is the connection to a…
Yoshi
  • 13
  • 1
  • 4
0
votes
1 answer

How can I make sure go through somewhere after thread be interrupted?

I create a thread for animated change image on ui scheduled. It will be interrupt while button click, and set an fixed image. But if setImage in runOnUiThread accidentally happen after setImage in onClick, it will be the wrong image. Is there any…
0
votes
2 answers

Android is not updating button background color on UI Thread

I am working on an app and trying to update Button background color using on click. What I want to do is, 1) Wait for 0.5 seconds to check answer is right or not. If answer is right, change button color to Green else change it to Red. 2) After…
Django Learner
  • 323
  • 1
  • 4
  • 12
0
votes
1 answer

Softkeyboard hide call not working as expected in view.post(), but works fine inside runOnUIThread()

When I make a call(from inside of a fragment) to hide the keyboard inside runOnUiThread() , the keyboard hides, but when I do the same from inside of activity.getCurrentFocus().post(), the keyboard does not hide. 1) Below code…
0
votes
2 answers

How to stop the handler which running on interval (1 min)?

I am developing an application, In which I am sending the device location to the server for every one min. I am using Handler here to schedule my task. After User click the STOP button, the handler should stop its execution. I am unable to achieve…
0
votes
2 answers

how do I dismiss my progress dialog after the needed function in alert dialog is applied?

I have a link in my fragment, which shows " click to open dialog" ,upon clicking it, an alert dialog pops up, showing " do you want to change the view? " with yes and no notations. If I click no, nothing happens and dialog dismisses as expected.…
0
votes
2 answers

Cannot change UI in runOnUiThread

I want change TextView content to the result of calculation in thread, but crashing when execution. Here's my code. new Thread(new Runnable() { public void run() { while (i < 5) { i++; } …
YH_WU
  • 73
  • 11
0
votes
2 answers

Android webview javascript interface method returns value before ui thread is finished

I am calling JavascriptInterface method from webview to call javascript methods. The problem is method returns value before getting result value. So how can I make return statement wait till javascript method is executed from ui…