Questions tagged [looper]

A JQuery plugin for carousel. No coding required.

It is a JQuery carousel plugin to cycle through content with minimal coding. It has minimal transition effects and uses JQuery's animate function. Keyboard navigation is also available.

190 questions
110
votes
5 answers

What is the relationship between Looper, Handler and MessageQueue in Android?

I have checked the official Android documentation/guide for Looper, Handler and MessageQueue . But I couldn't get it. I am new to android, and got very confused with these concepts.
Blake
  • 7,367
  • 19
  • 54
  • 80
78
votes
4 answers

How to create a Looper thread, then send it a message immediately?

I have a worker thread that sits in the background, processing messages. Something like this: class Worker extends Thread { public volatile Handler handler; // actually private, of course public void run() { Looper.prepare(); …
Thomas
  • 174,939
  • 50
  • 355
  • 478
78
votes
4 answers

Can't create handler inside thread that has not called Looper.prepare() inside AsyncTask for ProgressDialog

I don't understand why I'm getting this error. I'm using AsyncTask to run some processes in the background. I have: protected void onPreExecute() { connectionProgressDialog = new ProgressDialog(SetPreference.this); …
mlevit
  • 2,676
  • 10
  • 42
  • 50
31
votes
2 answers

AsyncTask and Looper.prepare() error

I have the following code class OverlayTask extends AsyncTask { @Override public void onPreExecute() { if (sites != null) { myMapView.getOverlays().remove(sites); myMapView.invalidate(); …
Lee Armstrong
  • 11,420
  • 15
  • 74
  • 122
27
votes
6 answers

How to raise a toast in AsyncTask, I am prompted to used the Looper

I have tasks completed by AsyncTask in background. At some point I need to issue a Toast that something is completed. I've tried and I failed because Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called…
Pentium10
  • 204,586
  • 122
  • 423
  • 502
14
votes
4 answers

How to better unit test Looper and Handler code on Android?

I use the android.os.Handler class to perform tasks on the background. When unit testing these, I call Looper.loop() to make the test thread wait for the background task thread to do its thing. Later, I call Looper.myLooper().quit() (also in the…
Marcelo Camelo
  • 176
  • 1
  • 7
12
votes
1 answer

What happens if a Handler posts a message to a thread after Looper.prepare() but before Looper.loop() has been called?

Consider the following snippet: Looper.prepare(); handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); getLooper().quitSafely(); } }; for(int i =…
Chad
  • 2,335
  • 8
  • 29
  • 45
11
votes
1 answer

Android Looper vs BlockingQueue?

Can anyone explain why someone should use the Android Looper feature to create a "pipeline thread" instead of making a normal thread that pulls tasks from a BlockingQueue? On the surface, it seems like two ways to do the same thing.
jfritz42
  • 5,913
  • 5
  • 50
  • 66
9
votes
5 answers

How to manage Loopers and Threads (thread doesn't die anymore!)

I created a class extending Thread to retrieve user location through LocationManager in a non-ui thread. I implemented this as a thread because it has to be started on request and do its work just for a limited time. By the way, I had to add a…
e-cal
  • 1,661
  • 2
  • 20
  • 28
9
votes
2 answers

CountDownTimer: "Can't create handler inside thread that has not called Looper.prepare()"

I know the general problem of "Can't create handler inside thread that has not called Looper.prepare()" has been asked before, but I am struggling to understand how it applies in this case. I am trying to construct a new CountDownTimer in a non-UI…
skaz
  • 21,962
  • 20
  • 69
  • 98
9
votes
2 answers

A/Looper: Could not create wake pipe. errno=24

We're building an app that does a lot of animations and downloads a lot of images. After a certain amount of transactions (a predictable number), the app is crashing with the error: A/Looper: Could not create wake pipe. errno=24 We don't use Looper…
Karim Varela
  • 7,562
  • 10
  • 53
  • 78
7
votes
2 answers

How to quit HandlerThread's looper safely

I have a HandlerThread, to which I keep posting a runnable every 5 seconds. Something like this: HandlerThread thread = new HandlerThread("MyThread"); thread.start(); Handler handler = new Handler(thread.getLooper()); handler.post(new Runnable() { …
sundie
  • 245
  • 3
  • 12
7
votes
2 answers

Where to "quit" with looper?

I have a problem with a looper. I call looper.prepare(), and after doing something it all works fine. But if I rotate the device I get an exception on the prepare. 07-12 16:40:09.760: E/activity(15809): java.lang.RuntimeException: Only one Looper…
Lele
  • 703
  • 3
  • 15
  • 34
6
votes
2 answers

Specifics on using Looper.prepare() in Android

I'm having a bit of trouble understanding how to use the Looper prepare()/loop()/quit() logic. I have three threads: one is the UI thread, one is a game logic thread and the last is a network communication thread (a background thread, lives only…
atheaos
  • 721
  • 2
  • 7
  • 16
6
votes
4 answers

Android: Only one Looper may be created per thread

I am having a problem with Android looper. I have a class that has extended AsynTask. Inside doInBackground() method i have Looper.prepare() and some code below. It runs well and good for the first time but after that it gives an exception " Only…
viv
  • 6,158
  • 6
  • 39
  • 54
1
2 3
12 13