[android-developers] Re: IntentService: Sending Message to a handler on dead thread

2010-09-19 Thread Samuh
Mark:

Thanks you very much for answering my questions.

 IntentService already uses a background thread for onHandleIntent().
 Hence, do not use AsyncTask -- just execute your code in
 onHandleIntent().

  2. How can such exceptions be avoided?

 Do not use AsyncTask -- just execute your code in onHandleIntent().

 Also, you might consider using a WakefulIntentService, or your own
 pattern derived from it, to keep the device awake while you are doing
 work:

 http://github.com/commonsguy/cwac-wakeful


I have removed the extra level of threading from the IntentService
class. Now, the logic runs inside onHandleIntent() and not as a
AsyncTask. Also, I am going to sub class your WakefullIntentService
class and see who things work out.

  3. What happens when the device sleeps?
 All processes and threads are suspended.

  4. I've read somewhere that if the network connectivity is through
  WiFi, it is disabled when the device sleeps.
 Correct.

  What are the cases that a
  developer should take care of when a device wakes up?
 That is impossible to answer in the abstract.

A few questions about WiFi states:

I am starting this service from an component which is invoked
periodically by the AlarmService. This service attempts to connect to
a remote server and fetch the data.  Assuming that a device goes to
sleep and Wifi connection is dropped, how should I code my remote
connection setup and data transfer calls?
Will the device still try to connect via WiFi, timeout and then try to
connect via GPRS or whatever?
What checks should I be doing? Should I listen to WiFi state changes
and use it somehow?

Presently, I have wrapped the remote connection call with a predicate
that checks the Network State. If the device is not connected to the
network(via any medium), an attempt is not made to connect to the
remote server.

If the official documentation details on this or If you've written
about it somewhere please share and oblige me.

Thanks again and have a nice day!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: IntentService: Sending Message to a handler on dead thread

2010-09-18 Thread Samuh
:bump:

Please help.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en