public void StartService()
        {
            _locMan = Application.Context.GetSystemService (Context.LocationService) as LocationManager;

            if (_locMan.GetProvider (LocationManager.GpsProvider) != null && _locMan.IsProviderEnabled (LocationManager.GpsProvider))
            {
                _pi = PendingIntent.GetBroadcast(Application.Context, 0, new Intent(), PendingIntentFlags.UpdateCurrent);
                _locMan.RequestLocationUpdates(LocationManager.GpsProvider, 2000, 5, _pi);
                _locMan.GetLastKnownLocation (LocationManager.GpsProvider);
            }

            else
                throw new GPSNotEnabledException (Const.NO_GPS_ERROR_MESSAGE);
        }
Exemplo n.º 2
0
 public Location getLoc()
 {
     locMgr = context.GetSystemService(Context.LocationService) as LocationManager;
       Criteria criteria = new Criteria();
       LocationProvider provider = locMgr.GetProvider("network");
       Location location = locMgr.GetLastKnownLocation(provider.Name);
       return location;
 }