예제 #1
0
        internal void Update(
            Context context, Kind kind, NotifyEvents notifyEvents, string contentFormat, params object[] args)
        {
            // Sometimes exception messages contain curly braces, which confuses string.Format
            this.ContentText = args.Length > 0 ? string.Format(CurrentCulture, contentFormat, args) : contentFormat;
            var showPopup = (int)kind >= (int)notifyEvents;

            if (showPopup)
            {
                #pragma warning disable CS0618                                                                      // Type or member is obsolete
                using (var builder = new Android.App.Notification.Builder(context))
                                                                                     #pragma warning restore CS0618 // Type or member is obsolete
                    using (var intent = new Intent(context, this.activityType))
                        using (var style = new Android.App.Notification.BigTextStyle())
                        {
                            // This is necessary so that the intent object is going to be interpreted as a new intent rather than
                            // an update to an existing intent.
                            intent.SetAction(this.id.ToString());

                            this.addArguments(intent);
                            builder
                            .SetSmallIcon(Resource.Drawable.ic_stat_name)
                            .SetContentTitle(this.title)
                            .SetContentText(this.ContentText)
                            .SetContentIntent(PendingIntent.GetActivity(context, 0, intent, 0))
                            .SetStyle(style.BigText(this.ContentText))
                            .SetAutoCancel(true);
                            SetLights(builder, kind);
                            this.manager.Notify(this.id, builder.Build());
                        }
            }

            Info("Notification{0}: {1}", showPopup ? " (shown in popup)" : string.Empty, this.ContentText);
        }
예제 #2
0
        public Android.App.Notification buildThis(NotificationCompat.Builder notificationBuilder, PendingIntent pendingIntent)
        {
            if (this.types.Count == 1)
            {
                if (this.types.First().bodys.Count == 1)
                {
                    var display = this.types.First();
                    notificationBuilder.SetContentTitle(display.notifType + " " + this.instrumentDisplayName)
                    .SetSmallIcon(Resource.Drawable.abc_list_divider_material)
                    .SetContentText(display.bodys.First())
                    .SetAutoCancel(true)
                    .SetShowWhen(false)
                    .SetContentIntent(pendingIntent);
                }
            }
            else
            {
                Android.App.Notification.BigTextStyle textStyle = new Android.App.Notification.BigTextStyle();

                string longTextMessage = "I went up one pair of stairs.";
                longTextMessage += " / Just like me. ";
                textStyle.BigText(longTextMessage);

                textStyle.SetSummaryText("The summary text goes here.");

                notificationBuilder.BigContentView.SetTextViewText(1, longTextMessage);//(textStyle);
            }



            return(notificationBuilder.Build());
        }