gpt4 book ai didi

Android Google Maps v2 - OnMyLocationChangeListener - 它究竟需要什么?

转载 作者:行者123 更新时间:2023-11-30 03:41:02 28 4
gpt4 key购买 nike

因为我不想混淆,所以我会尝试用 SDK 示例代码来解释。

一切正常 - 除了 "onMyLocationChange" 回调。

 - API 16 & 17 tested 
- updated Play Services Rev.5
- Tested with ICS Tablet&Phone

我刚刚添加了接收位置更新所需的内容:

UiSettingsDemoActivity implements OnMyLocationChangeListener

将其附加到 map 上:

mMap.setOnMyLocationChangeListener(this);

并实现回调

@Override
public void onMyLocationChange(Location arg0) {
....
}

但是这个方法永远不会被触发。

2 月 26 日的发行说明:https://groups.google.com/d/msg/google-maps-android-api-notify/va_IsjNu5-M/QPtoSn69UMgJ - 所以我认为这是可行的。

编辑:http://code.google.com/p/gmaps-api-issues/issues/detail?id=4644

最佳答案

您是否在应用程序中添加了 LocationListener?:

locationListener = new MyLocationListener();  
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);

我的位置监听器:

public class MyLocationListener implements LocationListener 
{
static final String TAG = MyLocationListener.class.getSimpleName();
@Override
public void onLocationChanged(Location location) {
SGTasksListAppObj.getInstance().currentUserLocation = location;
Log.d(TAG, "New location was set to currentUserLocation: "+location.toString());

}

@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}

@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}

}

更新:

也许你应该试试:

map.setMyLocationEnabled(boolean boolean);

方法,并检查此链接:

How to get My Location changed event with Google Maps android API v2?

关于Android Google Maps v2 - OnMyLocationChangeListener - 它究竟需要什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15753706/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com