コード例 #1
0
        public virtual PersistentNotification getPersistentNotification(int id)
        {
            // basic notification stuff
            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html
            int     icon         = getAppIcon();
            long    when         = java.lang.System.currentTimeMillis();
            Context c            = getApplicationContext();
            string  contentTitle = getPersistentNotificationTitle(id);
            string  contentText  = getPersistentNotificationMessage(id);
            string  tickerText   = contentTitle + ": " + contentText;

            // getPersistentNotification() is called for every new window
            // so we replace the old notification with a new one that has
            // a bigger id
            Intent notificationIntent = getPersistentNotificationIntent(id);

            PendingIntent contentIntent = null;

            if (notificationIntent != null)
            {
                contentIntent = PendingIntent.getService(this, 0,
                                                         notificationIntent,
                                                         // flag updates existing persistent notification
                                                         PendingIntent.FLAG_UPDATE_CURRENT);
            }

            Notification notification = new Notification(icon, tickerText, when);

            notification.setLatestEventInfo(c, contentTitle, contentText,
                                            contentIntent);
            var nn = new PersistentNotification
            {
                Notification = notification,

                id            = id,
                contentIntent = contentIntent,
                contentText   = contentText,
                contentTitle  = contentTitle,
                context       = c
            };

            PersistentNotifications.Add(nn);

            return(nn);
        }
コード例 #2
0
        public virtual PersistentNotification getPersistentNotification(int id)
        {
            // basic notification stuff
            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html
            int icon = getAppIcon();
            long when = java.lang.System.currentTimeMillis();
            Context c = getApplicationContext();
            string contentTitle = getPersistentNotificationTitle(id);
            string contentText = getPersistentNotificationMessage(id);
            string tickerText = contentTitle + ": " + contentText;

            // getPersistentNotification() is called for every new window
            // so we replace the old notification with a new one that has
            // a bigger id
            Intent notificationIntent = getPersistentNotificationIntent(id);

            PendingIntent contentIntent = null;

            if (notificationIntent != null)
            {
                contentIntent = PendingIntent.getService(this, 0,
                        notificationIntent,
                    // flag updates existing persistent notification
                        PendingIntent.FLAG_UPDATE_CURRENT);
            }

            Notification notification = new Notification(icon, tickerText, when);
            notification.setLatestEventInfo(c, contentTitle, contentText,
                    contentIntent);
            var nn = new PersistentNotification
                {
                    Notification = notification,

                    id = id,
                    contentIntent = contentIntent,
                    contentText = contentText,
                    contentTitle = contentTitle,
                    context = c
                };

            PersistentNotifications.Add(nn);

            return nn;
        }