/// <summary> /// New page /// </summary> public PageStart() { /// Text message to indicate current status textMessage.TextColor = Color.White; textMessage.Text = "[Start]\nWaiting for GPS signal.."; /// Content view of this page Content = new StackLayout() { VerticalOptions = LayoutOptions.Center, Children = { textMessage, } }; if (locator == null) { try { /// <summary> /// Create Locator instance, sets LocationType to GPS /// </summary> /// <param name="Hybrid">This method selects the best method available at the moment.</param> /// <param name="Gps">This method uses Global Positioning System.</param> /// <param name="Wps">This method uses WiFi Positioning System.</param> /// <param name="Passive">This method uses passive mode.</param> locator = new Locator(LocationType.Gps); /// Create GpsSatellite instance satellite = new GpsSatellite(locator); if (locator != null) { /// Starts the Locator which has been created using the specified method. locator.Start(); /// Add ServiceStateChanged event to receive the event regarding service state locator.ServiceStateChanged += LocatorServiceStateChanged; } } catch (Exception ex) { /// Exception handling textMessage.Text = "[Start] Exception \n" + ex.Message; } } }
/// <summary> /// Button event to start location service /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void ButtonStartClicked(object sender, EventArgs e) { if (locator == null) { try { /// <summary> /// Create Locator instance, sets LocationType to GPS /// </summary> /// <param name="Hybrid">This method selects the best method available at the moment.</param> /// <param name="Gps">This method uses Global Positioning System.</param> /// <param name="Wps">This method uses WiFi Positioning System.</param> /// <param name="Passive">This method uses passive mode.</param> locator = new Locator(LocationType.Gps); /// Create GpsSatellite instance satellite = new GpsSatellite(locator); if (locator != null) { /// Starts the Locator which has been created using the specified method. locator.Start(); textStatus.Text = "[Status] Start location service, GPS searching ..."; /// Add ServiceStateChanged event to receive the event regarding service state locator.ServiceStateChanged += Locator_ServiceStateChanged; /// Disable start button to avoid duplicated call. buttonStart.IsEnabled = false; // Enable available buttons buttonSatellite.IsEnabled = true; buttonStop.IsEnabled = true; } else { /// Locator creation failed textStatus.Text = "[Status] Location initialize .. Failed"; } } catch (Exception ex) { /// Exception handling textStatus.Text = "[Status] Location Initialize : " + ex.Message; } } }
public void OnGpsStatusChanged(GpsEvent e) { GpsStatus gpsStatus = locationManager.GetGpsStatus(null); if (gpsStatus != null) { IIterable satellites = gpsStatus.Satellites; IIterator sat = satellites.Iterator(); string lSatellites = null; int i = 0; while (sat.HasNext) { GpsSatellite satellite = sat.Next().JavaCast <GpsSatellite>(); Debug.WriteLine(satellite.Prn); } } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.MyButton); locationManager = (LocationManager)GetSystemService(Context.LocationService); locationManager.AddGpsStatusListener(this); locationManager.RequestLocationUpdates(LocationManager.GpsProvider, 0, 0, this); GpsStatus gpsStatus = locationManager.GetGpsStatus(null); if (gpsStatus != null) { IIterable satellites = gpsStatus.Satellites; IIterator sat = satellites.Iterator(); string lSatellites = null; int i = 0; while (sat.HasNext) { GpsSatellite satellite = sat.Next().JavaCast <GpsSatellite>(); Debug.WriteLine(satellite.Prn); } } button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); }; }
internal GpsNavMessage(GpsSatellite satellitePrn, DateTime dt, [NotNull] double[] clkData, [NotNull] double[] orbitParameters) : base(dt, clkData, orbitParameters) { SatellitePrn = satellitePrn; }