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

onPreExexute method is not called

I'm trying to display a Toast when I call the AsyncTask class with new saveWithStickers(BaseActivity.this).execute(); to notify the user that the save process being started, when I run the code below the onPreExecute() method for some logical reason…
0
votes
1 answer

Wait to receive data without blocking ui thread bluetooth android

I'm new to programming on android and I'm writing a simple application of a turn-based game that uses bluetooth. My app consists of Main Activity is responsible for starting a bluetooth connection and exchanging some configuration messages and a…
JayJona
  • 469
  • 1
  • 16
  • 41
0
votes
2 answers

Android - Runnable object parse into runOnUiThread() params

Please go through the steps, Created Actor class that inherited with Runnable public abstract class Actor implements Runnable { Actor(int queueSize){ } @Override public void run() { onInit(); } void onInit(){ // do stuff here }} Then I…
0
votes
1 answer

Activity.runOnUiThread(Runnable action) only updates view once

In my fragment, I have an AlertDialog and a Bluetooth connection manager. I want to update the AlertDialog with the new states of the Bluetooth connection process, so I used the runOnUiThread(...) method: getActivity().runOnUiThread(new Runnable()…
moictab
  • 959
  • 6
  • 27
0
votes
2 answers

Android - Call Thread synchronized on UI thread

I try to create synchronized threads, but I always get the following error: android.os.NetworkOnMainThreadException. I've read more posts, but they don't work for me. Below I write the code blocks that do not work for me: 1. final SyncApp syncJob =…
0
votes
1 answer

How to call Interstitial Ad in main activity and then call it in other activities?

I have 2 following activities - Main and GameOver. I want to declare all ad related data in MainActivity but show the ad when a button is clicked in the GameOverActivity. I have tried this: link My MainActivity: public class MainActivity extends…
0
votes
1 answer

Java Android Pass Function as an argument to runOnUiThread

I'm not a Java expert and I would like to understand how to pass a function that must be performed with runOnUiThread Something similar to this public void runOnActivity(FUNCTION) { mActivity.runOnUiThread( new Runnable() { …
Amedeo
  • 105
  • 1
  • 9
0
votes
0 answers

Update the textview text in runOnUiThread is overlapped with previously setted text

I want to set the textview text with the mediaplayer.getCurrentPosition() in runOnuiThread(). But problem is that the updated text is overlap with the previous set text. i am new to android and want to change text progmatically after some time that…
0
votes
1 answer

System.Threading: Running into Java.Lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

In my Xamarin.Android-App, when opening a special page (activity), there is a table displayed on create. A ListAdapter defines the certain fields within that table. I have a function which gets me an external int. The int is amongst other data…
Sam
  • 145
  • 1
  • 1
  • 12
0
votes
2 answers

android studio: change caracteristics of buttons in runOnUiThread block these buttons

I have two buttons: sell and buy. 1.When I click on sell I am calling setOnClickistener on the sell button. Inside I am creating a thread(I need it for a specific reason) and inside the thread I am using this code: runOnUiThread(new Runnable() { …
Bazouk55555
  • 557
  • 6
  • 24
0
votes
1 answer

Open dialog instantly and then load content for the dialog

Scenario: In my application, as I click on the button, it opens the dialog with WebView, loads some data (that involves copying, editing and loading the HTML file locally). The WebView is expected to display the HTML file created locally. What is…
0
votes
1 answer

runOnUiThread is not executing

I am trying to run this code but code inside my runOnUi thread is not executing. I am using evernote-android-job. He is the code which runs periodically: public class TempJob extends Job { public static final String TAG =…
0
votes
1 answer

Blinking in Recyclerview list

I am making Scoreboard app and It is working well but small issue is the Scoreboard is blinking Just for example: Shikhar Dhawan 86 (126) Rohit Sharma 20(20) the whole list is blinking in ms(millisecond) here is a short code: public class…
0
votes
1 answer

Using runOnUiThread to change TextView text in Android

I've got an app that makes API calls when the user logs in, I've got two classes, one that Pushes to the API and one that Pulls from it. I've also got an asyncTask on my LogIn Activity which handles the network connection. When the network…
Demonic218
  • 893
  • 2
  • 15
  • 33
0
votes
3 answers

Cross thread call a.k.a run on main/UI thread from other thread without dependencies needed

I'm on some c++ mobile product, but I need my apps main thread is still running without any blocking when doing some heavy work on the background thread and run back on main thread. But I realized there is no runOnMainThread/runOnUIThread in c++…
Oktaheta
  • 606
  • 5
  • 21