private void LocationGet_Clicked(object sender, EventArgs e) { DependencyService.Get <IProgressInterface>().Show(); loc = DependencyService.Get <IMyLocation>(); loc.locationObtained += (object sender1, ILocationEventArgs e1) => { var lat = e1.lat; var lng = e1.lng; LocationT.Text = "Latitude: " + lat.ToString() + " Longitude: " + lng.ToString(); if (LocationT.Text != null) { DependencyService.Get <IProgressInterface>().Hide(); } }; loc.ObtainMyLocation(); }
public MainPage() { InitializeComponent(); check(); loc = DependencyService.Get <IMyLocation>(); loc.locationObtained += (object sender, ILocationEventArgs e) => { var lat = e.lat; var lng = e.lng; x.Text = lat.ToString(); y.Text = lng.ToString(); }; notificationManager = DependencyService.Get <INotificationManager>(); notificationManager.NotificationReceived += (sender, eventArgs) => { var evtData = (NotificationEventArgs)eventArgs; ShowNotification(evtData.Title, evtData.Message); }; }
public override StartCommandResult OnStartCommand(Intent intent, [GeneratedEnum] StartCommandFlags flags, int startId) { Console.WriteLine("OnStartCommand"); CreateNotificationChannel(); //loc = DependencyService.Get<IMyLocation>(); string messageBody = "Aplikacja pobiera lokalizacje"; // / Create an Intent for the activity you want to start Intent resultIntent = new Intent(this, typeof(MainActivity)); // Create the TaskStackBuilder and add the intent, which inflates the back stack TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this); stackBuilder.AddNextIntentWithParentStack(resultIntent); // Get the PendingIntent containing the entire back stack PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, PendingIntentFlags.UpdateCurrent); var notification = new Notification.Builder(this, "10111") .SetContentIntent(resultPendingIntent) .SetContentTitle("Lokalizacja w tle") .SetContentText(messageBody) .SetSmallIcon(Resource.Drawable.navigation_empty_icon) .SetOngoing(true) .Build(); StartForeground(SERVICE_RUNNING_NOTIFICATION_ID, notification); loc = DependencyService.Get <IMyLocation>(); notificationManager = DependencyService.Get <INotificationManager>(); loc.locationObtained += (object sender, ILocationEventArgs e) => { var lat = e.lat; var lng = e.lng; x = lat; y = lng; string title = $"Aktualna lokalizacja"; string message = $"To: {x}|{y}"; notificationManager.SendNotification(title, message); Console.WriteLine(lat.ToString() + " " + lng.ToString()); }; loc.ObtainMyLocation(); return(StartCommandResult.Sticky); }