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
-3
votes
2 answers

How to use thread and handler to hit Web API?

My Boss told me Not to use AsyncTask<> to hit a webservice. Standard told me use Threads to hit a webservice and then use the Handler to process the response from Thread. Can someone ellobrate how to use thread and handler to hit a API and then give…
jot
  • 47
  • 1
  • 10
-3
votes
1 answer

Exception in AnimationUtils.loadAnimation() (sometimes)

I am getting a null pointer exception in the line given in code below. The problem is, the exception occurs randomly. Many times it just works but sometimes it throws an exception (say 5% of times). Any help would be appreciated. Handler handler =…
VipulKumar
  • 2,385
  • 1
  • 22
  • 28
-4
votes
3 answers

What is the difference between Handler vs runOnUiThread?

I come across both runOnUiThread and Handlers, but to me its still seems to be a doubt as on which facts do they differ exactly. What would be the best way to update UI? Should I use runOnUiThread or Handler? Already gone through link. Still not…
-4
votes
1 answer

NullPointerException Error

Am running a Primary App Processing App. However, I have encountered this issue of a NullPointerException. I have managed to identify where the source of the error is coming from, however, I am clueless on rectifying it. Could I get some help…
-5
votes
1 answer

Handler as a method parameter

Why some api have handler as a method parameter? What are the possible use cases? Specifically I need someone to explain why we need a handler in the dispatchgesture method. I am trying to perform drag operation on behalf of user using this…
sevenio
  • 31
  • 3
-5
votes
1 answer

Thread vs Handler vs Async task for sockets in android?

I'm going to write an Android server socket to connect with a Windows client. Which one is the best between Thread, Handler and Async task?
-5
votes
3 answers

How to use Handler in AsynkTask in android

I am fetching data from server using AsynkTask which works fine but I want to use handler in AsynkTask to reduce load from main Thread.How can I use Handler in AsynkTask. Kindly help me to solve this problem. Here is my code. public class…
rahul
  • 211
  • 1
  • 3
  • 9
-5
votes
1 answer

Change text after a while on Activity start

I have a text written in my app. I want it to be changed after some time automatically after the app starts. I need to invoke a method somewhere so that it can be called automatically. I've tried putting my code in onStart() method, but that delays…
1 2 3
56
57