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

Getting 'Unresolved reference' for 'runOnUiThread'

While trying to save an image I am getting the error message 'Unresolved reference:runOnUiThread' and also on the context terms inside the toast messages. The relevant code snippets are as below. I have tried all possible fixes, but failed. Please…
venu
  • 11
  • 2
0
votes
2 answers

is there any difference between runOnUiThread and CoroutineScope(Dispatchers.Main) in Kotlin Android

I don't know is there any difference between CoroutineScope(Dispatchers.Main).launch and runOnUiThread, I think both will run on Main thread. but still confusion is any difference there.? Thanks.
0
votes
0 answers

android Dialog Dismiss -> Only the original thread that created a view hierarchy can touch its views. when I using runOnUiThread

I am dismiss Dialog through RunOnUiThread. However, the error message is as follows. "Only the original thread that created a view hierarchy can touch its views." Can I know what to do? This is my code appleLoginDialog?.let { dialog -> …
Juro
  • 73
  • 1
  • 7
0
votes
1 answer

How to pass data that changes real-time from activity to fragment?

I am currently reading data from a Bluetooth Sensor, hence the data changes in real-time and continuously changes. I have stored the data in a variable: liveData:ByteArray Now I am trying to send liveData from MainActivity to…
Do Ji
  • 45
  • 1
  • 8
0
votes
1 answer

nullPointerException on calling getActivity().runOnUiThread{new Runnable inside Fragment

i'm trying to update my ListPreference summary inside my PreferenceFragment with timer while i'm inside my fragment everything is fine but as soon as i press the back button my app crashes and it throws a null pointer exception saying getActivity()…
Arad
  • 11
  • 5
0
votes
0 answers

Function being called twice in runOnUiThread Android Studio java

I have a JavascriptInterface that calls a function to draw in a layout. This function needs to be run on the UI Thread. I don't know why, but it is always called twice, making my app fail. Can someone help me? @JavascriptInterface public…
0
votes
1 answer

Polling in android when only app is not minimized

Lets say I have a method printCount() that print values every second, I want the polling to stop when the android app is minimized. For an example if it was minimized at count = 15 and if I open it after 5 mins, It should resume the polling and…
Sandeepa
  • 3,457
  • 5
  • 25
  • 41
0
votes
1 answer

Multi-thread runOnUiThread

I have a need to update the UI from a thread. In doing so, I created a Toast message to test that the function was working as expected. While in my thread, I run the function "runOnUiThread" and inside this function I place a Toast message, like…
EPAgg
  • 99
  • 1
  • 12
0
votes
1 answer

Activity not updating in tight loop

I have a situation where I want to update an Activity's text fields as data comes in. The update only occurs when the simulation is completed, not while it is running (takes maybe 2 seconds to run). Here is the code I have: ... private var…
0
votes
1 answer

How to update the listview from another thread with kotlin

I'm learning Android studio with Kotlin, I have setup one listview in Oncreate, it list out user data, then I have another function onOptionItemSelected which add/delete user data item, the problem is : after I add/delete from another function, the…
0
votes
1 answer

Is a Fragment on the UIThread?

When I first started my project, I updated the UI from all over the place. This worked for a while, because only a Seekbar was being updated from a worker thread and for some reason that worked. I then updated a TextView from the same worker thread…
John Glen
  • 771
  • 7
  • 24
0
votes
1 answer

Does runOnUiThread cause memory leak?

I am not sure if this code can cause a memory leak. Thread thread = new Thread(new Runnable() { @Override public void run() { runOnUiThread(new Runnable() { …
0
votes
1 answer

How to use runOnUiThread for updating a TextView

I have two threads in my main activity from Runner and start them with clicking a button. The only thing thy do is count up. I want to update two TextViews wit the current count from ech thread. When i start my app and click my button, the app…
0
votes
1 answer

ViewRootImpl$CalledFromWrongThreadException rxjava setVisibiltiy through rxjava

Hi Everyone currently I have a problem with threads in RXJava. I wanna set visible through rxjava but android throw me a this exception "ViewRootImpl$CalledFromWrongThreadException" Disposable disposable = Single.concat( …
0
votes
0 answers

Display Custom ProgressDialog while bitmap is saving in Gallery

I'm trying to display a custom dialog while bitmap saving in Gallery, I tried to use Asynthask and display the custom dialog in onPreExecute method and dismiss it in onPostExecute method. @SuppressLint("StaticFieldLeak") public class…