public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { if (NebliDex_Service != null) { return(StartCommandResult.Sticky); } //Do not reload the program again NebliDex_Service = this; // Reference itself so it can be used by other members RegisterForegroundService(); Task.Run(() => Start()); // The program will initialize in another thread return(StartCommandResult.Sticky); }
public override void OnDestroy() { // Remove the notification from the status bar. // And close the service var notificationManager = (NotificationManager)GetSystemService(NotificationService); notificationManager.Cancel(FORSERVICE_NOTIFICATION_ID); StopSelf(); StopForeground(true); base.OnDestroy(); NebliDex_Service = null; ExitProgram(); }
void Share (Service service, Button shareButton) { Item item = new Item { Text = "I'm sharing great things using Xamarin!", Links = new List<Uri> { new Uri ("http://xamarin.com"), }, }; Intent intent = service.GetShareUI (this, item, shareResult => { shareButton.Text = service.Title + " shared: " + shareResult; }); StartActivity (intent); }
public MyBinder(Service s) { serv = s; }