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
3
votes
1 answer

Android runOnUiThread not executing

I have this problem. I'm trying to update my TextView from another thread and it's not letting me. I have tried a bunch of different solutions and none of those didn't seem to help. In my while loop code is printing that "Started new loop" all the…
Sami Varis
  • 63
  • 9
3
votes
1 answer

run runOnUiThread() repeatedly causes exception

(2016.3.15 Updated) I encountered a strange problem last week and I'd like to discuss this with you. Problem Scenarios: There's a searchView in a AppCompatActivity. Whenever the text changed, the fragment within the Activity will be replaced through…
Zhou Hongbo
  • 1,297
  • 13
  • 25
3
votes
0 answers

requestSingleUpdate listener does not work

onLocationChanged event is not fired with requestSingleUpdate. It seems that it depends on the looper attached ex:…
2
votes
1 answer

runOnUIThread on android is unable to setfocus on the EditText and show soft keyboard

In my android application, the core logic is written in C++. Hence, for multiple scenarios, there will be JNI calls happening. In one use-case, as the text is being entered by the user in the 'EditText', I call a JNI method which will capitalize…
2
votes
0 answers

How can I intentionally crash my Xamarin Android application for not using RunOnUiThread?

I know this sounds like a weird question. I have a Xamarin.Android app. I'm going through my code and cleaning up stuff that was too aggressively wrapped with calls to RunOnUiThread. My understanding is that code that runs in response to UI events,…
Brian Rak
  • 4,912
  • 6
  • 34
  • 44
2
votes
1 answer

Can a post runnable get a null reference on the view it was run on?

When we are registering click listeners etc as common practice we check if the view is still there e.g. final View someView = ...; someView.setOnClickListener( (l) -> { if(someView != null) { // access view } }); since by the time…
Jim
  • 3,845
  • 3
  • 22
  • 47
2
votes
1 answer

Google fit integration UI Thread Error while requesting history result

While running the code on my button click app crashes instantly. Log shows following error Caused by: java.lang.IllegalStateException: await must not be called on the UI thread when time is greater than zero. at…
SARATH V
  • 500
  • 1
  • 7
  • 33
2
votes
0 answers

Why does runOnUiThread work for me while Handler.post does not

I have a Fragment that contains a RecyclerView. Within that Fragment, I load some data from a database, populate the RecyclerView with it and then want to scroll to a certain position in that RecyclerView. To perform the scrolling on the UI thread…
fjc
  • 5,590
  • 17
  • 36
2
votes
1 answer

Is this ok to run act.runOnUIThread when it's not a currently visible activity?

Let's say that I have a mainActivity and a reference to it everywhere. I switch activities later in the app and I'm not sure which is currently 'on the top' and if it's a mainActivity. Is it wrong to call mainActivity.runOnUIThread() when there's…
user6367252
2
votes
1 answer

ANR with code running on separate thread

Background: This app is a simple Wifi manager, collecting/scanning and displaying results in a list view. Since this scan scans on a interval, I have created a thread and set a Thread.sleep(interval) between scans, so after processing is done, it…
CybeX
  • 2,060
  • 3
  • 48
  • 115
2
votes
1 answer

NullPointerException in runOnUIThread()

I have created a movie application that queries a REST API at themoviedb.org. On selecting a movie from a grid the user is brought to a details screen where further details about the movie are shown details being a list of trailers and a list of…
2
votes
2 answers

How to Update UI inside volley response listener ? is runOnUiThread needed? or does Onresponse takes the control to UI Thread by itself?

while using volley library ,if i want to update the listview adapter inside Response listener , should it be done using runOnUiThread? or is it already in UiThread?
Siddarth G
  • 779
  • 11
  • 34
2
votes
3 answers

android postDelayed method doesn't work

I'm trying to do a splash screen for my app. i used the postDelayed method. this is my code: public class SplashScreenActivity extends Activity { private static final int SPLASH_DURATION_MS = 1500; private static final String TAG =…
user5214732
2
votes
0 answers

How to add Polyline to google map and show progress dialog in that time?

I want to show progress bar while polyline will be drawing on the screen. I know that Polyline is drawing only in UI thread. I have tried nextcode, but this doesn't helps. There was not progress dialog final Handler mHandler = new Handler(); …
2
votes
1 answer

Update ImageView's bitmap using UI-Thread

I have to manipulate pixels of a bitmap every one second, during another operation, and show the result in ImageView. This is a method that manipulates bitmap and updates ImageView: private void overlay(Bitmap bitmap) { int j = 70; while (flag) { …
1
2
3
12 13