Reputation: 489
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
Upvotes: 1
Views: 631
Reputation:
Its a long time since I have worked with any android stuff but built a location app last year and this is how I implemented the location listener and it all worked fine.
problems with android.location.geocoder
NOTE: Not all code at the link is relative to your problem but the structure may help
Upvotes: 0