我正试图通过onconnected方法中的location客户端请求位置更新。我的片段实现了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);
    }

错误是“找不到适用于requestlocationupdates(locationrequest,animatedmappfragment)的方法”,这非常令人困惑,因为在location client的文档中,有requestlocationupdates的定义。
public void requestlocationupdates(locationrequest请求,locationlistener侦听器)
有人看到我丢失的东西吗?

最佳答案

万一别人碰到这个问题,就想办法解决。确保正在导入:
com.google.android.gms.location.locationclient;
我正在导入android.location.locationclient。

09-25 21:35