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

Exception android.os.NetworkOnMainThreadException

When I try to run this code it gives my this error android.os.NetworkOnMainThreadException Here is the complete code: final EditText editText = (EditText) findViewById(R.id.ed); Button buttonX = (Button) findViewById(R.id.ok); …
0
votes
1 answer

android error only the original thread that created a view hierarchy can touch its views

i have class name Main1 that get array of image links & array of text from the main class and display them on listview. i get error "only the original thread that created a view hierarchy can touch its views" so i search for the solution i found…
Break Hart
  • 169
  • 1
  • 1
  • 7
0
votes
1 answer

Android service taking photos in background OnUiThread

I have service in which I want to take pictures of the user. I have a timer task myTimer = new Timer(); myTimer.schedule(new TimerTask() { @Override public void run() { TimerMethod(); } }, 0,…
davinci.2405
  • 247
  • 1
  • 4
  • 15
0
votes
1 answer

Update two TextViews inside a runnable

Can I update two textviews inside a runnable? Because my code can only update one textview. I got this method that updates 2 textviews that contains the address and date from the EXIF data of a photo. public void launchRingDialog() { final…
Jaye
  • 132
  • 1
  • 10
0
votes
2 answers

Android Thread runOnUiThread

I want to make a simple game, with one image view and two buttons to guess if the card is red of black. I want to use a thread, for every 0.1 seconds before the player presses the button, the card is changing. this is what i used so far : Thread…
cristi.gherghina
  • 311
  • 1
  • 6
  • 18
0
votes
2 answers

Running a method on UI thread

My question seems very simple but i can't seem to the logic right. Am trying to run methods from other classes using the UI thread. I could do this this simply by wrapping my methods like this runOnUiThread(new Runnable() { public void…
CodeZero
  • 179
  • 2
  • 15
0
votes
1 answer

Update GUI from Application Class

I am trying to show logs on a overlay over all activities. I found this https://stackoverflow.com/a/19037235/3370924 answer which implements the overlay in the application class. I have added a TextView to the LinearLayout to show my logs. At first…
lex
  • 77
  • 2
  • 9
0
votes
2 answers

Starting and stopping progressbar on UI thread from class

Is there a slicker/simpler way of doing the following? I have a method in a class that shows a progressbar while a thread runs. This code works but it just seems a little overly clunky having 3 steps. private void pause() { …
tallpaul
  • 1,220
  • 2
  • 13
  • 35
0
votes
0 answers

Android RunOnUIThread delays ListView Population

I'm using Azure Mobile Services to support my Android app and in this scenario, I'm trying to retrieve some database data using this method: new AsyncTask() { @Override protected Void doInBackground(Void...…
Jay
  • 4,873
  • 7
  • 72
  • 137
0
votes
2 answers

Error on ruOnUiThread inside asychtask

I am trying to parse some data from server and compare the data with the data in the database... Everything seems working fine... except I am getting only same value even the comparing data change... I'll explain it with the code... In the below…
Rishad Appat
  • 1,786
  • 1
  • 15
  • 30
0
votes
1 answer

Try-Catch for runOnUiThread

I want to catch some exception through my code, the code hierarchy is like the following: try { // some code 1 runOnUiThread(new Runnable() { @Override public void run() { // some code 2 …
Muhammed Refaat
  • 8,914
  • 14
  • 83
  • 118
0
votes
1 answer

Android - When does runOnUIThread take place?

I've got a separate thread that handles some information and needs to let the user know of an error if something comes up during its execution, so right now I'm calling runOnUIThread() in order to create a Dialog and let the user know. My question…
0
votes
0 answers

does runOnUiThread runs continuously

i have an Init_Params function which would be called from outside of the class, so i have done it like this below. which works fine. i need to know, is this runOnUiThread running in background continuously or run once when i called. i need to run it…
0
votes
0 answers

How to play music in Thread on Android?

I am trying to write code in Android to play music. But i am starting the music in a thread so music is breaking and i need to play the music in thread because i have receive the music name through a Bluetooth socket. So , the thread will keep…
MyCode
  • 289
  • 1
  • 5
  • 21
0
votes
1 answer

Android runOnUiThread to show progress dialog and to populate views

I usually work on .Net but I need to develop an Android app. So I am new on Android, sorry for mistakes in advance! :) Here is my story, I am populating a customer list(creating ui elements in code behind) with views in a button click. I am doing…