• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Unable to implement LocationListener

I'm trying to make an app that just gets gps coordinates and displays them. I found that you need to do LocationManager.requestLocationUpdates() in order to get it to work, but this requires you to have an implemented LocationListener as a parameter. I've found tons of sites showing how to do this, and they're all doing it basically the same way, but for some strange reason it won't work for me. Here's my implementation:


Code:
private class MyLocationListener implements LocationListener 
    {
        @Override
        public void onLocationChanged(Location loc) {
            if (loc != null) {
                Toast.makeText(getBaseContext(), 
                    "Location changed : Lat: " + loc.getLatitude() + 
                    " Lng: " + loc.getLongitude(), 
                    Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void onProviderDisabled(String provider) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProviderEnabled(String provider) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStatusChanged(String provider, int status, 
            Bundle extras) {
            // TODO Auto-generated method stub
        }
    }

Now when I try to run it it gives errors on each of the overridden methods. They're all basically the same. Here's the one for OnLocationChanged:
The method onLocationChanged(Location) of type HelloViaSocket.MyLocationListener must override a superclass method

Everything I've seen says that LocationListener should have OnLocationChanged and all the other methods I'm trying to override, so why is it doing this?

I tried deleting my Google API's from the SDK, and then re-downloading and installing them, but I'm getting the same problem.

Does anyone have any idea what I'm doing wrong?

Bretterson
 
I had the same problem on Eclipse Helios, but i had az another project, what works fine.
The problem was that, the project folder in the .settings had source set to 1.5.
After remove the .settings folder, it compiled without any warning.
 
Back
Top Bottom