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

running 2 methods asynchronously

I have 2 methods in onCreate which I need to run one after the other ie...the second method will start once the first method is complete irrespective of how much time it takes.Please help me. new Handler().postDelayed(new Runnable() { /* …
user8601021
  • 219
  • 3
  • 18
-1
votes
1 answer

Android: java.lang.RuntimeException caused by Handler

Good Morning! I have an android app in the google play store with a widget that load some data from server. In my Play-Console I get the following exception: java.lang.RuntimeException: at android.os.AsyncTask$3.done (AsyncTask.java:318) at…
user3849220
-1
votes
2 answers

NullPointerException in Floating Action Button in Fragment

can you help me with this error: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.design.widget.FloatingActionButton.setOnClickListener(android.view.View$OnClickListener)' on a null object reference …
-1
votes
1 answer

How to know from context values which activity is currently running foreground?

I have a tricky situation. I will try to fully explain it in the best possible way. My app has few activities, say A, B, C. A is the Main Activity and B & C gets called from A. So basically when B or C is running, A will be stopped(onStop()). I am…
NewOne
  • 401
  • 5
  • 19
-1
votes
1 answer

Timer task implementing handler

UPDATE : The code is working only that I dint init the textview, but this question is answered so I cant remove it either. So I will leave this question as it is for anyone trying to implement a Timertask with handler that makes use of…
user3599100
-1
votes
2 answers

How do I send an interrupt to a handler to break a Thread.sleep()?

I have a Handler that is inside a Service and I block this thread until the user chooses to stop the service. To make it less CPU intensive I am trying to use Thread.sleep() and repeat checking the blocking condition after an interval of 10…
Sourav Kanta
  • 2,727
  • 1
  • 18
  • 29
-1
votes
1 answer

Not able to understand Runnable in android

Here is my code: public class MainActivity extends AppCompatActivity { Runnable runnable; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); …
-1
votes
3 answers

Handler Thread - NetworkOnMainThread exception (android.os.handler)

This is not a duplicate of the question posted above. As HAndlerThread starts a newThread and i get a NetworkOnMainThread exception, i think it is a strange error. It is entirely new issue to solve that normal NetworkOnMainThread exception. Kindly…
-1
votes
1 answer

Run method in every 30 minutes from android remote service

I have a service which runs on remote process(via AIDL interface). It is a unstoppable service (which starts on boot complete and last until uninstalling the app). This service keep listening to UDP socket. I want to run function in this service in…
-1
votes
1 answer

TimerTask / Handler with Delay getting called Multiple times

I need a delay for around 5 seconds. I have tried using Timer using below code : Timer myTimer = new Timer(); myTimer.schedule(new TimerTask() { @Override public void run() { …
BLEdevices
  • 11
  • 3
-1
votes
1 answer

I cant receive text sent from thread to UI

here is my hander: public Handler handler = new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); String mmsg = msg.getData().getByteArray("msg").toString(); …
-1
votes
1 answer

handler.postDelayed doesn't execute

I want to make app in Android that scans all the networks every 5sec. To can all networks repeatedly I use handler.postDelayed. The task() and wi() function should be executed. task() seems to work but wi() doesn't. Any idea why? public class…
-1
votes
1 answer

Android: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

I am making an android app where I am trying to get location using location manager and then I push that location to a server. When I try to do this I am getting the following error. java.lang.RuntimeException: Can't create handler inside thread…
varunkr
  • 5,364
  • 11
  • 50
  • 99
-1
votes
1 answer

Cannot read response returned from volley

I am using volley to get some data from a web service. I'm using the following format to read responses from volley. I make volley requests calling methods which are defined like below and I show a progressDialog when the volley request…
SripadRaj
  • 1,687
  • 2
  • 22
  • 33
-1
votes
2 answers

killing a task in android by handler

I am scheduling few functions by using timer handler.This is what happens. When i press the button the timer starts sending sms and it opens another activity. Then in the another activity i have put the stop button to terminate the timer and return…
user4323984