【发布时间】:2012-08-02 09:52:00
【问题描述】:
我需要在整个应用程序中实现一个 LocationListener。
我知道我可以将服务与 LocationListener 一起使用,但问题是我必须在位置更改时使用一些通知程序。当我想要随时获得最后一个位置时,这还不够,因为当它发生变化时,我需要立即在所有活动中的当前位置。
所以在伪代码中我需要这样的东西:
myLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {
public void onLocationChanged(Location location) {
notifyAllActivities(location);
}
};
在每个活动中:
void onNotify(Location location) { //... }
【问题讨论】:
-
接受一个对你有用的答案,这样其他人可能会觉得它有用。
标签: android gps location locationmanager locationlistener