No Suitable Method Found For RequestLocationUpdates
Solution 1:
You are using the wrong LocationListener
class. You need to replace this:
import com.google.android.gms.location.LocationListener;
with this:
import android.location.LocationListener;
The com.google.android.gms.location
stuff is for use with the FusedLocationProviderApi
which is part of Google play services.
The standard Android location stuff is in android.location
.
Also, you have GetCurrentLocation extends Activity
. But it isn't really an Activity
. You need to remove the extends Activity
clause. This will then cause problems because you are calling getBaseContext()
in some methods of that class. To fix this, have the constructor of GetCurrentLocation
take a Context
parameter and save that in a private member variable. Then use that when you need a Context
instead of calling getBaseContext()
.
In MainActivity
, when you create a new GetCurrentLocation
, you can do this:
LocationListener locationListener = new GetCurrentLocation(this);
passing this
as the Context
parameter (Activity
extends Context
).
Solution 2:
The error telling you that there is no overload method requestLocationUpdates
that accepts parameters (String,int,int,com.google.android.gms.location.LocationListener)
The closer method is
requestLocationUpdates(String provider, long minTime, float minDistance,
LocationListener listener);
So possible solution to fix your error is:
long t = 5000;
float d = 10;
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, t, d, locationListener);
Refer Android LocationManager for more details
Post a Comment for "No Suitable Method Found For RequestLocationUpdates"