And since Blake was too shy to mention his own web site and book, let me do it for him;) The coverage of these issues in "Programming Android" is better than in many Android books, and in his webcast "Concurrent Programming in Android" is even better.
IntentService is so handy, I am amazed it got so little coverage in Android Developer documentation all this time. Even with the vast improvements in the 4.0 docs, IntentService is still under-documented. There is a lot you can do with either this or Looper/Handler without having to resort to AsyncTask, which really has been over-billed in recent years as if far more flexible and useful than it really is. On Wednesday, January 30, 2013 4:54:16 AM UTC-8, G. Blake Meike wrote: > > First of all, congrats for not doing this with an AsyncTask. > > Second, as of Honeycomb, you may not touch the network from the UI thread > (as you've probably surmised by now). The fact that you are getting that > error message suggest to me that you are using a Handler *attached to the > UI thread* You can't do that. > > TreKing's suggestion of an alarm, scheduled with the alarm manager, > coupled with an intent service, is probably a good way to go. The Alarm > manager fires a PendingIntent at the IntentService. When the IntentService > gets the intent, it runs the server check. > > -blake > > > On Tuesday, January 29, 2013 11:47:39 AM UTC-5, Diego Nunes wrote: >> >> Good afternoon. >> >> I need from time to time do a check on a server, because I'm not using >> AsyncTask do not need no update from my view. >> >> Then I used a Handler that runs a thread from time to time, and this >> thread makes access to the server. In Honeycomb versions running down blz, >> already in top get a exception: android.os.NetworkOnMainThreadException. >> >> Someone uses a different strategy to do this kind of task? >> >> Thank you. >> >> --------------------------------------- >> Diêgo Nunes Assunção >> "Give Peace a Chance" >> > -- -- 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 --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

