Questions tagged [android-handlerthread]

Handler is part of the Android system's framework for managing threads. A Handler object receives messages and runs code to handle the messages. Normally, you create a Handler for a new thread, but you can also create a Handler that's connected to an existing thread. When you connect a Handler to your UI thread, the code that handles messages runs on the UI thread. This way results of background work can be moved to UI elements such as bitmaps.

79 questions
0
votes
1 answer

how to stop notification thats in handler thread

I have a custom notification that has four RemoteView TextViews. When onPause() gets called I want to post the notification and then update it every second while the screen is on. When onResume() gets called I want to cancel the notification. So far…
0
votes
1 answer

Why would a background thread spawn its own Handler & Looper

Why would a background thread spawn its own Handler & Looper just to modify UI's component .I know that in simple terms: Looper : Loop and execute tasks in a message queue Handler : posting the tasks to the queue Have a look at this snippet I took…
0
votes
5 answers

Is there a way to call a method in UI thread from a background thread almost instantaneously?

This is not the problem about being able to call a method in the main/UI thread but being able to do so instantaneously. It is my knowledge that you are not normally allowed to interact with the UI thread directly because of the UI responsive…
Manish Kumar Sharma
  • 12,982
  • 9
  • 58
  • 105
0
votes
1 answer

How to stop a blocked handler thread?

I have bind an activity to a remote service through aidl interface. Various other activities are also bound to it. After some point of time, calls are getting blocked. When I open that particular activity it starts a handlerthread and it is calling…
Gambler
  • 31
  • 4
0
votes
1 answer

HandlerThread's handleMessage() is not called

I just came through a strange problem when using HandlerThread and Handlers (By Handlers i mean android.os.handler). I am trying to pass message from my Fragment to a separate Handler Thread. I just setup a handleMessage to handle message. But it is…
0
votes
0 answers

Why ViewRootImpl$CalledFromWrongThreadException is not precise?

A snippet with updating TextView line-to-line (via setText() old line to new one) from non-UI thread: TextView mLog; final static String ONE_LINER; // Condition 1: update from loopless thread new Thread(new Runnable() { @Override public…
0
votes
1 answer

Timing of using android IPC mechanisms

There are several methods to do IPC in Android - Content Provider, Message, AIDL, Async Task, IntentService ... Seems like each of them aims to solve particular problem. How to decide which I should use? I need a service keep running in background,…
0
votes
0 answers

Android executing simple Asynchronous task via Thread/Runnable/Handler/Looper approach

I am tasked with displaying a random number after a 5 second delay using Thread.sleep(5000), on a button click using the Handler/Looper/Thread/Runnable approach rather than implementing an AsyncTask. My problem is, I'm having issues finding examples…
0
votes
2 answers

Got IllegalThreadStateException when Invoking HandlerThread.start() second time after HandlerThread.quit()

First time ,i invoke HandlerThread.start() to handle the background service. after all the stuffs completed,I wanna to end this Thread by calling HandlerThread.quit(). Then the second time,I start this Handler,and checked the…
Lee
  • 25
  • 10
0
votes
1 answer

Loss of messages in HandlerThread

I have a class that extends a HandlerThread class for creating a bitmap from photo on the device in GridView when it's needed but from time to time instead of creating a bitmap of photo it fils a GridView item(ImageView) with nothing and i cant…
0
votes
0 answers

Can't send message to inner handler class from thread class

Let say I have following class... private class SignalRConnection extends Thread { private final int CONNECT = 0; private final int STOP = 1; private SignalRHandler signalRHandler = null; @Override public…
0
votes
1 answer

How to use a HandlerThread to juggle 2 Threads

I have a class that extends HandlerThread and implements Handler.Callback. I can't understand how to setup the Handlers to send messages back and forth to each other under this scheme. My Handler1 needs to talk to Handler2 and vice versa but…
0
votes
1 answer

How to efficiently update and get data from a SQLite database on Android?

I am making an app which gets a time schedule from a website and display it in my app in a nice ListView. To make the schedule available when the user is offline I am trying to save it in a SQLite database first and get the data from there. The idea…
Obe
  • 13
  • 5
0
votes
0 answers

HandlerThread null exception - Android

I'm using ThreadHandler in my app this way, public class MessageThread extends HandlerThread { Handler mHandler; public MessageThread() { super("Message Thread"); } public void queueProcessMessage(msgObject mObj) { …
0
votes
1 answer

HandlerThread safety in Android

Ok, this is a question I didn't think needed asking but either its the long hours or whatnot, but my mind is foggy so here it goes. Creating a class with a HandlerThread, Looper, and Handler: public class MyClass { //private volatile boolean…
Vadym
  • 964
  • 1
  • 13
  • 31