请按照代码行..
Step1: into your oncreate
LocationListener locationListener = new LocalLocationListener();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
Step2: into class body
/**Listener on location change*/
private class LocalLocationListener implements LocationListener
{
public void onLocationChanged(Location location)
{
String text = "My current Location is: "+location.getLatitude()+", "+location.getLongitude();
GeoPoint geoPoint = new GeoPoint((int)(location.getLatitude()* 1E6), (int)(location.getLatitude() * 1E6));
mapController_.animateTo(geoPoint);
Toast.makeText(LocalMap.this, text, Toast.LENGTH_SHORT).show();
Log.i("onLocationChanged", text);
}
public void onProviderDisabled(String provider)
{
// TODO Auto-generated method stub
Toast.makeText(LocalMap.this, "GPS Disable", Toast.LENGTH_SHORT).show();
Log.i("onProviderDisabled", "GPS Disable");
}
public void onProviderEnabled(String provider)
{
// TODO Auto-generated method stub
Toast.makeText(LocalMap.this, "GPS Enable", Toast.LENGTH_SHORT).show();
Log.i("onProviderEnabled", "GPS Enable");
}
public void onStatusChanged(String provider, int status, Bundle extras)
{
// TODO Auto-generated method stub
}