Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Location Client cannot resolve method

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?

like image 599
Zach Sperske Avatar asked Mar 21 '23 04:03

Zach Sperske


1 Answers

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.

like image 164
Zach Sperske Avatar answered Mar 31 '23 16:03

Zach Sperske