We are starting an IntentService periodically using AlarmManager
service. The IntentService class fires a few AsyncTask from its
onHandleIntent() callback.
The setup works well for some time. But when the device is put to
sleep or if the application is exited and resumed after some time,
whenever the IntentService code runs, I get the following exceptions:
Handler{44f1b3a8} sending message to a Handler on a dead thread
java.lang.RuntimeException: Handler{44f1b3a8} sending message to a
Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:181)
at android.os.Handler.sendMessageAtTime(Handler.java:457)
at android.os.Handler.sendMessageDelayed(Handler.java:430)
at android.os.Handler.sendMessage(Handler.java:367)
at android.os.Message.sendToTarget(Message.java:317)
at android.os.AsyncTask$3.done(AsyncTask.java:214)
at java.util.concurrent.FutureTask$Sync.innerSet(FutureTask.java:
252)
at java.util.concurrent.FutureTask.set(FutureTask.java:112)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:
310)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:
1068)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
When I run the code on the thread that is executing onHandleIntent()
the occurences of this error is minimized. However, I am not sure if
the possibility of it happening is zero.
Questions:
1. What is causing these exceptions?
2. How can such exceptions be avoided?
3. What happens when the device sleeps?
4. I've read somewhere that if the network connectivity is through
WiFi, it is disabled when the device sleeps. What are the cases that a
developer should take care of when a device wakes up?
Please help.
Thanks.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en