Hi,
I am developing a GPS based application, and for my application I
need to get the current location, and also need to update the UI as and when
the location changes. So for that I am using Location Manager and location
listener package as follows,
public class HelloMapViewSec extends MapActivity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager lm = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
myLocationListener = new MyLocationListener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
myLocationListener);
Location myLocation = lm.getLastKnownLocation("network"); //using "gps"
returned NULL
if(myLocation != null)
{
lat = myLocation.getLatitude() * 1E6;
lng = myLocation.getLongitude() * 1E6;
GeoPoint point = new GeoPoint(lat.intValue(),lng.intValue());
//And had an overlay to point in MapView
}
}
//MyLocationListener Class defined for instantiating a location listener
private class MyLocationListener implements LocationListener
{
public void onLocationChanged(Location loc)
{
if (loc != null)
{
Toast.makeText(getBaseContext(),
"Location changed : Lat: " + loc.getLatitude() +
" Lng: " + loc.getLongitude(),
Toast.LENGTH_SHORT).show();
}
}
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
System.out.println("GPS : Provider Disabled" + provider);
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
System.out.println("GPS : Provider Enabled" + provider);
}
public void onStatusChanged(String provider, int status,
Bundle extras) {
// TODO Auto-generated method stub
System.out.println("GPS : Status Changed to " + provider + "[" +
status + "]");
}
}
}
I am able to get the current user details using the above code, but I am not
able to see the LocationListener's onLocationChanged() functionality getting
called within a distance coverage of 10/100m. I have tried by changing the
minDistance parameter of lm.requestLocationUpdates() from 10 to 100, but
still I dont see any quick response. I need a call to LocationListener's
onLocationChanged() functionality within 10/100m so that I can do
speed/distance calculations.
On further analysis I saw that the onLocationChanged() will be called on a
500m change only.
How can I make the a call to LocationListener's onLocationChanged()
functionality within 10/100m travel?
If not possible then is there any alternate method/means for calculating the
speed/distance travelled by user?
Thanks and regards,
Ruppin.
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en