Questions tagged [android-handler]

A Handler allows you to send and process `Message` and Runnable objects associated with a thread's `MessageQueue`. Each Handler instance is associated with a single thread and that thread's message queue. When you create a new Handler, it is bound to the thread / message queue of the thread that is creating it -- from that point on, it will deliver messages and runnables to that message queue and execute them as they come out of the message queue.

A Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue. Each Handler instance is associated with a single thread and that thread's message queue. When you create a new Handler, it is bound to the thread / message queue of the thread that is creating it -- from that point on, it will deliver messages and runnables to that message queue and execute them as they come out of the message queue.

848 questions
0
votes
1 answer

How important is it for the message handler in a service to be static?

Consider a fairly basic service: class KeepANumberService extends Service { // The codes used in incoming messages final static int REQUEST_SET_NUMBER = 0; final static int REQUEST_GET_NUMBER = 1; // The information this service…
Neil Townsend
  • 6,024
  • 5
  • 35
  • 52
0
votes
1 answer

Scheduling a database update and shows a dialog

Ok, I think this is a recurring question, sorry for that. I need to update my DB collecting some data from web and display a dialog while the data are being downloaded. I have my dialog, data comes fine and writes in database. I'm doing some…
learner
  • 1,311
  • 3
  • 18
  • 39
0
votes
2 answers

What is the difference between Handler (MessageQueue) and AsyncTask (SERIAL_EXECUTOR), performance wise?

There are a couple ways of getting data Asynchronously in your app. One is a Handler and another one is an AsyncTask. Now I've used both, and would like to know which one performs better/more efficiently at some tasks. Thusfar, I've mostly used…
tolgap
  • 9,629
  • 10
  • 51
  • 65
0
votes
2 answers

Multiple handlers reusable code

Can some please suggest an alternative to using two different handlers in the one activity, or let me know that this method is OK? Details: I'm in the process of developing some code for use with Microchips ADK Android starter kit. Everything is…
PaulEaster
  • 5
  • 2
  • 4
0
votes
2 answers

Android Handler.getLooper() returns null

I have following problem. I have this implementation of my Thread with Looper. public class GeoLocationThread extends Thread{ public Handler handler; private General general; public void run(){ Looper.prepare(); handler = new…
ziky90
  • 2,627
  • 4
  • 33
  • 47
0
votes
3 answers

how can start intent after finishing download an image from url?

I need to start my intent after finishing the download of the image from the url without any action from the user of the application itself. This is my activity which first will download the image and after that it will start the intent. …
0
votes
1 answer

Action Bar for Android 2.2, Handler not updating by UI

I am trying to abstract out and create a Action Bar (for Android 2.2). Hence I am writing it out myself. For some reason I am not able to get the HomeScreen to update the actionbar. It may not be a handler issue, something more basic than that I…
Siddharth
  • 9,349
  • 16
  • 86
  • 148
-1
votes
1 answer

What to pass in as type handler for Bluetooth class for data transfer?

I am working on an Android app to communicate wirelessly with an Arduino over Bluetooth with an HC-05. I have been following the Transfer Bluetooth data documentation from Android. The following code is what I am using to send and receive data. …
-1
votes
1 answer

How to define a task, run it in the future, and cancel it using Kotlin coroutines

I'm new to kotlin Coroutines. I define a Runnable and call it asynchronously in a function using Handler with a delay. The important thing is that the previous task must be canceled before each call so that it is not performed after the delay. This…
-1
votes
2 answers

When I run my app for the first time, don't you think runTimer() method will run infinitely and so the onStart() method will never get called?

My OnStart() method should not get called because my onCreate() method will run infinitely. When OnCreate method runs, the runTimer() method gets called. This runTimer method will run infinitely because of handler.postDelayed. How is it that Android…
-1
votes
1 answer

Why is New Handler is deprecated?

public class SpalshScreen extends AppCompatActivity { FirebaseUser currentUser; private FirebaseAuth mAuth; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); …
-1
votes
1 answer

How to run the handler.postDelayed after the app is killed in Android studio?

This is the handler which is I want to run always except the phone switch off val handler = Handler() val runnable: Runnable = object : Runnable { override fun run() { val geoPoint =…
-1
votes
3 answers

Attempt to invoke virtual method 'android.os.Looper android.os.Handler.getLooper()' on a null object reference

A bit of a background here, I came from Ionic so I'm still a noob when it comes to java and android studio. So I followed this article in medium and I stumbled a lot with declaring global variables specifically... Here's my code public class…
-1
votes
1 answer

Calling a function to update my UI in background

I found that if I include this code productPrice.setText(MyLeanCloudApp.getInstance().userTotalCharge.getPriceRangeString(product, context));, my gridview would not able to scroll smoothly. ArrayAdapter class @Override public View getView(int…
-1
votes
1 answer

Android timer,Broadcast Receiver,

Developing a timer application, Have 4 buttons start--Will start the timer stop-- will stop timer pause--will pause timer lap time--will calculate lap time. when button click it s working Good. Now i am Modify the application like timer should…