我正试图在onConnected方法中通过位置客户端请求位置更新。我的片段实现了LocationListener、GooglePlayServicesClient.ConnectionCallbacks和GooglePlayServicesClient.OnConnectionFailedListener。
代码如下:
public class AnimatedMapFragment extends SupportMapFragment
implements LocationListener,
GooglePlayServicesClient.ConnectionCallbacks,
GooglePlayServicesClient.OnConnectionFailedListener {
private LocationRequest mLocationRequest;
private LocationClient mLocationClient;
...
mLocationRequest = LocationRequest.create();
mLocationRequest.setInterval(5000);
mLocationRequest.setFastestInterval(1000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationClient = new LocationClient(this.getActivity(), this, this);
...
@Override
public void onConnected(Bundle bundle) {
mLocationClient.requestLocationUpdates(mLocationRequest, this);
}
错误提示为"no suitable method found for requestLocationUpdates(LocationRequest, AnimatedMapFragment)",这很令人困惑,因为在位置客户端文档中,有这样一个requestLocationUpdates的定义:
public void requestLocationUpdates (LocationRequest request, LocationListener listener)
有没有人看出我错过了什么?
LocationListener
,你应该导入com.google.android.gms.location.LocationListener
。我为此奋斗了三个小时! - Nirmal