문제

I'm trying to request location updates via the location client in the onConnected method. My fragment implements LocationListener, GooglePlayServicesClient.ConnectionCallbacks, and GooglePlayServicesClient.OnConnectionFailedListener.

Code looks like this.

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);
    }

And the error is "no suitable method found for requestLocationUpdates(LocationRequest, AnimatedMapFragment)" Which is highly confusing because in the docs for location client, there is this definition of requestLocationUpdates.

public void requestLocationUpdates (LocationRequest request, LocationListener listener)

Does anyone see what I'm missing?

도움이 되었습니까?

해결책

In case others run into this problem, just figured it out. Make sure you are importing:

com.google.android.gms.location.LocationClient;

I was importing android.location.LocationClient.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top