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

App crashes on clicking on same item

I have this adapter plays music on button click. Its all working when I click a song that is already playing to stop, the app crashes. Can someone help me with this one - I'm trying to figure out for two hours now. Here is my adapter public class…
Darko Petkovski
  • 3,892
  • 13
  • 53
  • 117
0
votes
2 answers

Update UI through Handler

I need to update my UI from an external Thread. I can't use runOnUiThread, because it's an application using StandOut libraries. So I created my Handler in the class containing methods to update the UI: private final class UIHandler extends Handler…
Vektor88
  • 4,841
  • 11
  • 59
  • 111
0
votes
1 answer

Handler wont SetText on Button

In my Application I am trying to simply setText() on my Button purchaseButton. I have an Alert Dialog that takes a value and initializes an AsyncTask to complete the server call to find the discount. All of that works fine, its when I get to the…
Keeano
  • 309
  • 8
  • 33
0
votes
1 answer

How do I put AsyncTask code to Thread Handler

I'm trying to develop an android app that could list all app and their cache's. But I'm facing a problem that whenever I tap on generated list I'm getting force close because java.lang.IllegalStateException: The content of the adapter has changed…
Chethan Shetty
  • 1,972
  • 4
  • 25
  • 45
0
votes
2 answers

edittext clear text after n seconds

I want to empty an EditText based on a timer, according to the following behaviour: At time t1, the user starts typing. The EditText should be cleared at time t1 + 10 seconds. Once the EditText has been cleared, the timer should stop. When…
user900785
  • 423
  • 3
  • 14
  • 32
0
votes
0 answers

Main thread blocks AsyncTask

I want to start a service from an activity. The activity keeps on doing its own work even after calling the service. So, I have used AsyncTask to start the service. But my service does not start until the main thread stops executing. My services…
0
votes
1 answer

how to show the dialog in certain interval of time in all activity?

In my application am going to show the dialog in particular time interval,for the time interval am using runnable method in separate class. My runnable method class public class Timeout_function{ Handler mHandler; Activity activity; public…
Yugesh
  • 4,030
  • 9
  • 57
  • 97
0
votes
1 answer

Call a method in variable period on everytime?

I have to call some webservice method in variable times, every time method runs it returns me next period time as long. I tried it with timer but after first calling, it can not understand new variable time. This is the link asked yesterday…
John simit
  • 1,305
  • 2
  • 11
  • 14
0
votes
0 answers

Timer time does not change as variable?

Here is my code, private int V_Time = 1; . . . try { final Timer V_Timer; final Handler V_Handler; V_Timer = new Timer(); V_Handler = new Handler(Looper.getMainLooper()); V_Timer.scheduleAtFixedRate(new TimerTask() { public void run() { …
John simit
  • 1,305
  • 2
  • 11
  • 14
0
votes
1 answer

Error on Android Handler update interface

Handler handler = new Handler() { public void handleMessage(Message msg) { super.handleMessage(msg); ReturnShow.setText(sMsg);//ReturnShow EditText ReturnShow.setSelection(ReturnShow.length()); } }; class ReadThread…
Miss.seven
  • 13
  • 4
0
votes
1 answer

Updating interface handler issue

So I have these lines of codes in my android app, wifiScrollViewText is of type String, I set to whatever message I want to append to the ViewText: wifiScrollViewText through the handler ... The readableNetmask in my case is 255.255.255.0 , and the…
spac3hit
  • 191
  • 9
0
votes
1 answer

How to call the handler from separate class in android?

In my application, am try to set an time out function i not able to call the handler method in separate class. My Timeout Class public class Timeout_function { private Handler mHandler; Activity activity; public Timeout_function(Activity…
Yugesh
  • 4,030
  • 9
  • 57
  • 97
0
votes
1 answer

Null pointer error due to thread not stopping before orientation change

I have a fragment that displays weather data that runs a background thread that essentially just calls a function in my main UI to check whether my forecast is still valid. This function updates the UI so I am using a Handler and posting a Runnable…
ccbunney
  • 2,282
  • 4
  • 26
  • 42
0
votes
1 answer

calling another activity function inside an activity via handler doesn't work

I want to start a CountDownTimer from another activity. I use handlers to do that, but it doesn't work. Which part am I doing wrong? This is my code: activity1.java : public class Activity1 extends Activity { public static Handler mHandler;…
Fcoder
  • 9,066
  • 17
  • 63
  • 100
0
votes
1 answer

Uncaught Handler error.

I am trying to do a HTTP Post and as I came to know that time consuming tasks should be used within a Async Task or a Handler, I tried to code it using a Handler but I am getting an Handler uncaught exception, Unable to determine where I am going…
Skynet
  • 7,820
  • 5
  • 44
  • 80