FYI - ..... and in fact, it does:
http://www.netmite.com/android/mydroid/frameworks/base/location/java/android/location/LocationManager.java
Constructor for ListenerTransport (a helper class that delivers updates
to the application):
if (looper == null) {
mListenerHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
_handleMessage(msg);
}
};
} else {
mListenerHandler = new Handler(looper) {
@Override
public void handleMessage(Message msg) {
_handleMessage(msg);
}
};
}
Implementation of _handleMessage():
switch (msg.what) {
case TYPE_LOCATION_CHANGED:
Location location = new Location((Location) msg.obj);
mListener.onLocationChanged(location);
break;
..... cases for other msg.what are snipped .....
-- Kostya
29.09.2010 23:26, Kostya Vasilyev пишет:
Being able to specify a Looper in requestLocationUpdates seems to
imply that LocationManager uses Looper/Message mechanism to deliver
location updates to the application.
Using the UI Looper seems safe then, since location update messages
would be delivered to the main thread, decoded into Java callback
method calls, and invoked as usual.
--
Kostya Vasilyev -- http://kmansoft.wordpress.com
29.09.2010 21:13 пользователь "ADRA" <dche...@gmail.com
<mailto:dche...@gmail.com>> написал:
I could be wrong about this due to inexperience, but due to the nature
of the looper, if you put it on the main looper and the GPS decides to
randomly disappear for seconds then the GUI freezes along with it. I
don't know if that really happen in reality, but I imagine the
possibility could occur. If you want to make sure that the location
updates don't mess up your UI you could always do something like:
class MyLocThread extends Thread
{
public MyLocThread ()
{
setDaemon(true);
setName("LocationThread");
}
public void run()
{
Looper.prepare();
lm.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
0L,
0L,
locListenerGPS,
Looper.getLooper()
);
Looper.loop();
}
}
On Sep 29, 8:35 am, Pent <tas...@dinglisch.net
<mailto:tas...@dinglisch.net>> wrote:
> Is there anything wrong with specifyi...
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
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