1. Check out our app, Forums for Android! Download and leave feedback here!

Unable to implement LocationListener

Discussion in 'Application Development' started by Bretterson, Dec 21, 2009.

  1. Bretterson

    Bretterson New Member
    Thread Starter
    5

    Dec 21, 2009
    1
    0
    5
    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 (Text):
    1. private class MyLocationListener implements LocationListener
    2.     {
    3.         @Override
    4.         public void onLocationChanged(Location loc) {
    5.             if (loc != null) {
    6.                 Toast.makeText(getBaseContext(),
    7.                     "Location changed : Lat: " + loc.getLatitude() +
    8.                     " Lng: " + loc.getLongitude(),
    9.                     Toast.LENGTH_SHORT).show();
    10.             }
    11.         }
    12.  
    13.         @Override
    14.         public void onProviderDisabled(String provider) {
    15.             // TODO Auto-generated method stub
    16.         }
    17.  
    18.         @Override
    19.         public void onProviderEnabled(String provider) {
    20.             // TODO Auto-generated method stub
    21.         }
    22.  
    23.         @Override
    24.         public void onStatusChanged(String provider, int status,
    25.             Bundle extras) {
    26.             // TODO Auto-generated method stub
    27.         }
    28.     }
    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
     

    Advertisement

  2. KeithG

    KeithG Well-Known Member
    46

    Nov 15, 2009
    103
    3
    46
    remove the @override annotations.
     
  3. lugosi

    lugosi New Member
    5

    May 16, 2011
    1
    0
    5
    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.
     

Share This Page

Loading...