raul
raul

Reputation: 1269

Error in parameters to LocationServices.FusedLocationApi.requestLocationUpdates()

I'm following this example from http://developer.android.com to get location updates. I get the following error when trying to call the LocationServices.FusedLocationApi.requestLocationUpdates() method. Please help me resolve this.

enter image description here

When I let Android Studio fix the issue for me, it does the following: enter image description here This, however, results in the following error:

java.lang.ClassCastException: com.example.user.myapplication.MainActivity cannot be cast to com.google.android.gms.location.LocationListener

Upvotes: 0

Views: 643

Answers (2)

kenneth
kenneth

Reputation: 1

my solution was import com.google.android.gms.location.LocationListener; and delete import android.location.LocationListener;

Upvotes: 0

raul
raul

Reputation: 1269

Phew! I had forgotten to implement the LocationListener class in my activity.java like so:

public class MainActivity extends Activity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener { ... }

Upvotes: 1

Related Questions