On Tue, Jun 23, 2009 at 2:43 PM, Richard Schilling < [email protected]> wrote:
> > Trying to get my head around the specific ins/outs of the Looper > object and how it interacts with Threads. Documentation is rather > scant on this topic. This is one of those topics that is obvious to > the Android core team, but to the rest of us, it's not so obvious. > > Can someone point us to better documentation or give a more complete > account of Looper: > > 1. What is looper. It's the thing that makes sure that messages sent to a Handler actually end up there. 2. How does the Android phone use Looper to coordinate message > handling? Not sure what you mean by "coordinate" in this context. 3. What do I need to do when I get the "Can't create handler inside > thread that has not called Looper.prepare()" message? You call Looper.prepare() before you create the Handler, then some time later you call Looper.loop() to start the message handling loop, exactly as done in the sample code at the top of http://developer.android.com/reference/android/os/Looper.html If you don't want your message processing to be done in that thread, create the Handler somewhere else (your main application thread for example). 4. How do I use LocationManager.requestLocationUpdates with Looper, > and why does this call require a Looper object? Because internally those updates are sent as Messages, so a Handler is needed to receive them, so you need a Looper to run the message loop. You don't *have* to specify a Looper, but in that case the calling thread must have a Looper. For example, you can call the non-Looper method from your app's main thread. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

