I want to get the current location of the user in my app. Everytime i use the LocationManager
get this error:
The method requestLocationUpdates(String, long, float, LocationListener) in the type LocationManager is not applicable for the arguments (String, int, int, MainActivity).
This is my code:
public class MainActivity extends ActionBarActivity implements LocationListener
{
private GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
//I get error in this line
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
}
@Override
protected void onResume()
{
super.onResume();
}
@Override
public void onLocationChanged(Location location)
{
// TODO Auto-generated method stub
double latitude = (double) (location.getLatitude());
double longitude = (double) (location.getLongitude());
Log.i("Geo_Location", "Latitude: " + latitude + ", Longitude: " + longitude);
}
}
Also LocationListener implementations throws me an error, and must be implemented like this android.location.LocationListener
Any help I will really appreciate.
PD: I'm using Eclipse