problem in getting updated GPS location?

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

problem in getting updated GPS location?

Postby mr_muskuraha » Fri Oct 29, 2010 8:40 am

dear friends,

i am using following code to get GPS location.

but problem i am facing is
if move from one city to another or somewhere in the town it does not update my GPS location and brings me last location it got.

please guide what mistake am i doing in this code?

Code: Select all
public class MyLocationTutorial extends MapActivity
{

public Location loc;
    LocationManager mlocManager ;
    LocationListener mlocListener;

  @Override
    public void onCreate(Bundle savedInstanceState)
    {

--
---
---

mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
             mlocListener = new CurrentLocationListener();
             mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
             loc = mlocManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);


if(loc != null)
          {


MyDeviceLatitude = loc.getLatitude();
            MyDeviceLongitude = loc.getLongitude();

}
else
          {
             
             
                  mlocManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 0, 0, mlocListener);
                  loc = mlocManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

MyDeviceLatitude = loc.getLatitude();
            MyDeviceLongitude = loc.getLongitude();
                  



}


// location class

   public class CurrentLocationListener implements LocationListener{

       public void onLocationChanged(Location argLocation)
       {
          if (argLocation != null)
          {
             
             loc = argLocation;
             
             //MyDeviceLatitude = argLocation.getLatitude();
             //MyDeviceLongitude = argLocation.getLongitude();
          }

       }
       public void onProviderDisabled(String provider) {
       }

       public void onProviderEnabled(String provider) {
       }

       public void onStatusChanged(String provider, int status, Bundle arg2) {
       }
       }





}


any help would be appreciated.
mr_muskuraha
Senior Developer
Senior Developer
 
Posts: 142
Joined: Wed Jan 13, 2010 8:49 am

Top

Return to Map Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests