Esempio n. 1
0
        protected virtual void SendNotification()
        {
            this.builder ??= new NotificationCompat.Builder(this.Context.AppContext)
            .SetChannelId(NotificationChannelId)
            .SetSmallIcon(this.AndroidNotifications !.GetSmallIconResource(null))
            .SetOngoing(true);

            this.builder
            .SetProgress(
                this.Service !.Total,
                this.Service.Progress,
                this.Service.IsIndeterministic
                )
            .SetContentTitle(this.Service.Title ?? "Shiny Service")
            .SetTicker("..")
            .SetContentText(this.Service.Message ?? "Shiny service is continuing to process data in the background");

            if (this.notificationId == null)
            {
                this.notificationId = ++idCount;
                this.StartForeground(this.notificationId.Value, this.builder.Build());
            }
            else
            {
                this.AndroidNotifications !.NativeManager.Notify(this.notificationId.Value, this.builder.Build());
            }
        }