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
1 answer

Progress bar is not working in android

MainActivity Code import android.support.v4.app.Fragment; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.View; import…
user3732316
  • 63
  • 1
  • 7
-1
votes
2 answers

Pause thread inside for cycle (android)

today i started to write a simple android aplication. The idea is that method "click(View v)" witch is called when the button is pressed, will change background of a TextField to random color after 1 second for let's say 30 times (long story short:…
-1
votes
1 answer

Concept : Does Handlers also execute network request sequentially as like AsyncTask

Hello As you know that AsyncTask by default run your network request sequentially until you use Executor. Does Handlers also execute network request sequentially ? If not then how to run them parallel ?
Mick
  • 1,179
  • 5
  • 14
  • 24
-1
votes
1 answer

Handler.postDelayed error on runtime

If I use handler.postDelayed with the following order (delaying startAnimation): animFadeout = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.disappear); animFadeout.setAnimationListener(this); Handler handler = new…
Kfir
  • 157
  • 1
  • 3
  • 11
-1
votes
1 answer

Cannot do switch/case statement in handler

I have encountered a problem in my Android application where my switch/case statment won't work in my handler. The main reason I did the switch/case statement is to limit the amount of handlers I have. Here is my part of my code: if…
user2507301
  • 153
  • 1
  • 15
-1
votes
1 answer

Change the button color after a variable time

I'm having a problem to change the button color after a certain amount of time. I know how to change using handle after a fixed time, but I need to change the color after a specific time that is chosen by the user. public class MainActivity extends…
-2
votes
1 answer

Application crashes when sending messages from main UI thread to some other thread

I am trying to send message from my onCreate() method of MainActivity to the Connection thread which then sends the data to the server via udp socket. But the app crashes continuously. Please tell me how to send data from the UI thread to non-UI…
Usama Ahmed
  • 66
  • 11
-2
votes
2 answers

Run an if-statement for a certain amount of time

I want to check if an int value is higher than 20 for a certain amount of 15 minutes, if that int value stays higher than 20 in those 15 minutes, code will executed I didn't understand the difference between a Handler and a Runnable, how to use…
captindfru
  • 233
  • 1
  • 3
  • 13
-2
votes
1 answer

How to perform click continuously while something is enable

I'm beginner... I need to run some code after 10 seconds continuously while my button is enable. and when I clicked on it and it turned to disable-state, timer get stop. I use below code but it run just once when I click on timerbutton every time…
-2
votes
2 answers

How to use handler to capture images at regular intervals?

After one click on capture button, I need to take images at regular intervals. I have written the code using Handler. But what happens now is that, I need to click button at each capture of images. What I want is to click on the button only once and…
HMD
  • 9
  • 6
-2
votes
2 answers

What is the best way communication between threads?

Actually I am using retrofit inside of project , and I am calling 2 Aysnc requests. but I need that after this requests success to trigger other method. how to know when this request are done and then trigger other method ?
cnkaptan
  • 15
  • 1
  • 7
-2
votes
4 answers

Unable to show ProgressDialog in AsyncTask

I am trying to show ProgressDialog in AsyncTask(). In my code i am using handler.postdelayed to run AsyncTask. Without handler.postdelayed it's showing the progressdialog. final Handler handler = new Handler(); handler.postDelayed(new Runnable()…
-2
votes
2 answers

Method in Toggle Button crashes

Hey guys I am having an issue that a method I am trying to run every thirty seconds is causing my toggle button to crash. My goal is to send data to a database based on the button click, and while the toggle button is on to continue sending that…
Shawn
  • 2,355
  • 14
  • 48
  • 98
-3
votes
2 answers

initialization problem but already iinitialized Kotlin

When i try to run my app the error shows that you have init the adapter i already init it and after i init it. it shows that reyclerview must be also init but as i do that already i don't get a solution please do helpful Thanks in Advance. The Code…
-3
votes
1 answer

Synchronize handler thread

I am running a recursive handler which runs some code. I am posting the handler using a HandlerThread. I want to run the next recursive call only after the completion of the previous call. Is it possible to do so? If not what are the alternatives. …
Naman Mehta
  • 26
  • 10
1 2 3
56
57