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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With