1. Are you ready for the Galaxy S20? Here is everything we know so far!

Unable to implement LocationListener

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

  1. Bretterson

    Bretterson Lurker
    Thread Starter

    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
     



    1. Download the Forums for Android™ app!


      Download

       
  2. KeithG

    KeithG Well-Known Member

    remove the @override annotations.
     
  3. lugosi

    lugosi Lurker

    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.
     
Loading...
Similar Threads - Unable implement LocationListener
  1. chiques
    Replies:
    3
    Views:
    618
  2. jhall68w
    Replies:
    5
    Views:
    844
  3. Ajrox22
    Replies:
    9
    Views:
    951
  4. MarcoGalaxyA10
    Replies:
    1
    Views:
    1,549
  5. FaustBottomText
    Replies:
    4
    Views:
    1,693
  6. xarzu
    Replies:
    2
    Views:
    1,482
  7. GlitchedFolx
    Replies:
    16
    Views:
    3,541
  8. aj4yourhelp
    Replies:
    0
    Views:
    1,404
  9. Ian Preddy
    Replies:
    13
    Views:
    6,928
  10. Magixsword
    Replies:
    0
    Views:
    1,249

Share This Page

Loading...