You have to write: setLocationListener in the activity On 6 Jun., 04:27, Lance Nanek <[email protected]> wrote: > http://code.google.com/p/android/issues/detail?id=2545 > > On May 25, 8:35 am, Squ36 <[email protected]> wrote:> Hi all. I'm > trying to develop a small app, that can retrieve GPS > > coordinates, and store them, so I can retrace the path I took. The > > thing is, the GPS on Android emulator is kind of screwing around with > > my nerves... > > First of all, the Mock Position system doesn't work, so I'm manually > > fixing the coordinates with telnet "geo fix" command. > > Second of all, the location listener seems to not be refreshing. I'm > > lauching the app, fixing a first set of coordinates, and observing the > > response I expect. But when I push a second set of coordinates, the > > app simply doesn't react. > > > I tried a lot -big lot- of ideas on this, and I'm kind of running > > short... > > > By the way, I'm developping on Eclipse with ADT, and the SDK for > > Android 1.5 (French HTC Heros are still with Android 1.5) so that I > > can use my own app. > > > Here's my code (just the coordinate retrieval part) : > > > / > > *************************************************************************/ > > /***********Android GPS Coordinates Retrieval System*************/ > > / > > *************************************************************************/ > > > package com.GPS; > > > import android.app.Activity; > > import android.content.Context; > > import android.location.Location; > > import android.location.LocationListener; > > import android.location.LocationManager; > > import android.os.Bundle; > > import android.widget.Toast; > > > public class GPS extends Activity > > { > > public void onCreate(Bundle savedInstanceState) > > { > > super.onCreate(savedInstanceState); > > setContentView(R.layout.main); > > /* Use the LocationManager class to obtain GPS locations */ > > LocationManager mlocManager = (LocationManager) > > getSystemService(Context.LOCATION_SERVICE); > > LocationListener mlocListener = new MyLocationListener(); > > > > mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1, > > 1, mlocListener); > > } > > > /* Class My Location Listener */ > > public class MyLocationListener implements LocationListener > > { > > @Override > > public void onLocationChanged(Location loc) > > { > > loc.getLatitude(); > > loc.getLongitude(); > > String Text = "My current location is: " + > > "Latitude = "+ > > loc.getLatitude() + "Longitude = " + loc.getLongitude(); > > Toast.makeText(getApplicationContext(), Text, > > Toast.LENGTH_SHORT) > > .show(); > > } > > @Override > > public void onProviderDisabled(String provider) > > { > > Toast.makeText(getApplicationContext(), "Gps > > Disabled", > > Toast.LENGTH_SHORT).show(); > > } > > @Override > > public void onProviderEnabled(String provider) > > { > > Toast.makeText(getApplicationContext(), "Gps > > Enabled", > > Toast.LENGTH_SHORT).show(); > > } > > @Override > > public void onStatusChanged(String provider, int status, > > Bundle > > extras) > > {} > > }/* End of Class MyLocationListener */ > > > } > > > / > > *************************************************************************/ > > > Thanks in advance for anyone who will spend some of his time helping > > me :)
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

