Пример #1
0
        private PendingIntent InitResultIntentBasingOnViewModel(NotificationViewModel notificationViewModel)
        {
            // When the user clicks the notification, SecondActivity will start up.
            Intent resultIntent;

            // Construct a back stack for cross-task navigation:
            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(NotificationContext);

            if (OnboardingStatusHelper.Status == OnboardingStatus.CountriesOnboardingCompleted &&
                notificationViewModel.Type == NotificationsEnum.NewMessageReceived.Data().Type)
            {
                resultIntent = new Intent(NotificationContext, typeof(MessagesActivity));
                stackBuilder.AddParentStack(Class.FromType(typeof(MessagesActivity)));
            }
            else
            {
                resultIntent = new Intent(NotificationContext, typeof(InitializerActivity));
                stackBuilder.AddParentStack(Class.FromType(typeof(InitializerActivity)));
            }

            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            return(stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent));
        }
Пример #2
0
        private void ShowWalkNotification()
        {
            // When the user clicks the notification, SecondActivity will start up.
            Intent resultIntent = new Intent(this, typeof(WalkActivity));

            // Construct a back stack for cross-task navigation:
            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);

            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(WalkActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            //create notification for walk-screen
            NotificationCompat.Builder nBuilder = new NotificationCompat.Builder(this)
                                                  .SetSmallIcon(Resource.Drawable.Icon)
                                                  .SetContentTitle("Are you stressed?")
                                                  .SetContentIntent(resultPendingIntent)
                                                  .SetContentText("Maybe a short walk would do good?")
                                                  .SetPriority((int)NotificationPriority.High)//priority is high because user can be in danger!
                                                  .SetAutoCancel(true);

            //publish the notification
            NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);

            notificationManager.Notify(10001, nBuilder.Build());
        }
        void HandleTimerCallback(object state)
        {
            var preferences     = PreferenceManager.GetDefaultSharedPreferences(this);
            var streamerNames   = preferences.GetString("streamer_names", "").Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            var streamersOnline = Twitch.StreamersOnline(streamerNames, configuration);

            foreach (var entry in streamersOnline)
            {
                if (!entry.Value)
                {
                    continue;
                }

                Bundle valuesForActivity = new Bundle();
                Intent resultIntent      = new Intent(this, typeof(MainActivity));
                resultIntent.PutExtras(valuesForActivity);

                TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);
                stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
                stackBuilder.AddNextIntent(resultIntent);

                PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

                NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                     .SetAutoCancel(true)
                                                     .SetContentIntent(resultPendingIntent)
                                                     .SetContentTitle("Streamer online")
                                                     .SetSmallIcon(Resource.Drawable.Icon)
                                                     .SetContentText(entry.Key + " is streaming now");

                NotificationManager notificationManager = (NotificationManager)GetSystemService(NotificationService);
                notificationManager.Notify(ButtonClickNotificationId, builder.Build());
            }
        }
        private void HandleMessage(Context context, Intent intent)
        {
            Intent           resultIntent = new Intent(this, typeof(MainActivity));
            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);
            var c = Class.FromType(typeof(MainActivity));

            stackBuilder.AddParentStack(c);
            stackBuilder.AddNextIntent(resultIntent);
            string        alert               = intent.GetStringExtra("Alert");
            int           number              = intent.GetIntExtra("Badge", 0);
            var           imageUrl            = intent.GetStringExtra("ImageUrl");
            var           title               = intent.GetStringExtra("Title");
            Bitmap        bitmap              = GetBitmap(imageUrl);
            PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                 .SetAutoCancel(true)                   // dismiss the notification from the notification area when the user clicks on it
                                                 .SetContentIntent(resultPendingIntent) // start up this activity when the user clicks the intent.
                                                 .SetContentTitle(title)                // Set the title
                                                 .SetNumber(number)                     // Display the count in the Content Info
                                                 .SetSmallIcon(Resource.Drawable.Icon)  // This is the icon to display
                                                 .SetLargeIcon(bitmap)
                                                 .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
                                                 .SetContentText(alert); // the message to display.
            // Build the notification:
            Notification notification = builder.Build();
            // Get the notification manager:
            NotificationManager notificationManager =
                GetSystemService(Context.NotificationService) as NotificationManager;
            // Publish the notification:
            const int notificationId = 0;

            notificationManager.Notify(notificationId, notification);
        }
        public override void OnReceive(Context context, Intent intent)
        {
            reminder = ReminderHelper.SelectReminder(context);
            if (reminder != null)
            {
                Intent newIntent = new Intent(context, typeof(ReminderContent));
                newIntent.PutExtra("reminder", JsonConvert.SerializeObject(reminder));

                //Add the next task to the stack
                Android.Support.V4.App.TaskStackBuilder stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(context);
                stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(ReminderContent)));
                stackBuilder.AddNextIntent(newIntent);

                // set the intent which will open when one click on notification
                PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

                NotificationCompat.Builder builder = new NotificationCompat.Builder(context).SetAutoCancel(true)
                                                     .SetDefaults((int)NotificationDefaults.All)
                                                     .SetContentIntent(resultPendingIntent).SetContentTitle("Reminder!!")
                                                     .SetSmallIcon(Resource.Drawable.notify_panel_notification_icon_bg).SetContentText("Click for details..")
                                                     .SetContentInfo("Start");
                NotificationManager notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService);
                notificationManager.Notify(2, builder.Build());
            }
        }
Пример #6
0
        private void CreateNotification(SongBundle song)
        {
            Log(Type.Info, "Creating notification");

            Intent info = new Intent(Application.Context, typeof(MainActivity));

            info.PutExtra("NotificationSong", JsonConvert.SerializeObject(song));

            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(Application.Context);

            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
            stackBuilder.AddNextIntent(info);

            PendingIntent resultIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            NotificationCompat.Builder builder = new NotificationCompat.Builder(this, ChannelId)
                                                 .SetAutoCancel(true)
                                                 .SetContentTitle(Resources?.GetString(Resource.String.app_name))
                                                 .SetContentText(song.Normal.Artist + " - " + song.Normal.Title)
                                                 .SetSmallIcon(Resource.Drawable.ic_stat_name)
                                                 .SetContentIntent(resultIntent)
                                                 .SetPriority(-1);

            ntfManager = NotificationManagerCompat.From(Application.Context);
            ntfManager.Notify(NotificationId, builder.Build());
            Log(Type.Event, "Notification made!");
        }
        public override void OnReceive(Context context, Intent intent)
        {
            PendingIntent pi      = PendingIntent.GetActivity(context, 0, intent, 0);
            AlarmManager  manager = (AlarmManager)context.GetSystemService(Android.Content.Context.AlarmService);

            manager.Cancel(pi);

            // When the user clicks the notification, SecondActivity will start up.
            Intent resultIntent = new Intent(context, typeof(MainActivity));

            // Construct a back stack for cross-task navigation:
            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(context);

            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            //Build Notification
            NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                                                 .SetAutoCancel(true)
                                                 .SetDefaults((int)NotificationDefaults.Sound)
                                                 .SetContentIntent(resultPendingIntent)
                                                 .SetContentTitle("Notification ALARM!!!")
                                                 .SetSmallIcon(Resource.Drawable.ic_stat_button_click)
                                                 .SetContentText(string.Format("You are OUT!!."));

            //Send Notification
            NotificationManager nf = (NotificationManager)context.GetSystemService(Context.NotificationService);

            nf.Notify(1000, builder.Build());

            MainActivity.CloseThis();
        }
        private void SendMyNotification(string title, string description, string channelID, string channelName, string channelDescription, bool serviceNotification)
        {
            // When the user clicks the notification, SecondActivity will start up.
            Intent        resultIntent = new Intent(this, typeof(MainActivity));
            PendingIntent resultPendingIntent;

            if (serviceNotification)
            {
                resultPendingIntent = null;
            }
            else
            {
                resultIntent.SetAction("Main_Activity");
                resultIntent.SetFlags(ActivityFlags.SingleTop | ActivityFlags.ClearTask);

                // Construct a back stack for cross-task navigation:
                Android.Support.V4.App.TaskStackBuilder stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(this);
                stackBuilder.AddParentStack(Class.FromType(typeof(MainActivity)));
                stackBuilder.AddNextIntent(resultIntent);

                // Create the PendingIntent with the back stack:
                resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);
            }

            //Build Notification
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelID)
                                                 .SetAutoCancel(true)
                                                 .SetContentIntent(resultPendingIntent)
                                                 .SetContentTitle(title)
                                                 .SetSmallIcon(Resource.Drawable.notification_icon_background)
                                                 .SetOngoing(true)
                                                 .SetContentText(string.Format(description));

            NotificationManager nf = (NotificationManager)GetSystemService(NotificationService);

            //Creating a Channel
            if (Build.VERSION.SdkInt > BuildVersionCodes.O)
            {
                // Notification channels are new in API 26 (and not a part of the support library). There is no need to create a notification
                // channel on older versions of Android.
                NotificationChannel nc = new NotificationChannel(channelID, channelName, NotificationImportance.Default)
                {
                    Description = channelDescription
                };

                nf.CreateNotificationChannel(nc);
            }

            //Send Notification
            if (serviceNotification)
            {
                StartForeground(10000, builder.Build());
            }
            else
            {
                nmc = NotificationManagerCompat.From(this);
                nmc.Notify(1000, builder.Build());
            }
        }
Пример #9
0
        /*
         * void createNotification(string title, string desc)
         * {
         *      //Create notification
         *      var notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;
         *
         *      //Create an intent to show ui
         *      var uiIntent = new Intent(this, typeof(MainActivity));
         *
         *      //Create the notification
         *      var notification = new Notification(Android.Resource.Drawable.SymActionEmail, title);
         *
         *      //Auto cancel will remove the notification once the user touches it
         *      notification.Flags = NotificationFlags.AutoCancel;
         *
         *      //Set the notification info
         *      //we use the pending intent, passing our ui intent over which will get called
         *      //when the notification is tapped.
         *      notification.SetLatestEventInfo(this, title, desc, PendingIntent.GetActivity(this, 0, uiIntent, 0));
         *
         *      //Show the notification
         *      notificationManager.Notify(1, notification);
         * }
         */

        private void updateNotification(int num, string msg, int notificationID, string url)
        {
            // These are the values that we want to pass to the next activity
            Bundle valuesForActivity = new Bundle();

            valuesForActivity.PutInt(GF.CALL_FROM_NOTI_TYPE, notificationID);
            valuesForActivity.PutString(GF.URL_FROM_NOTI, url);

            // Create the PendingIntent with the back stack
            // When the user clicks the notification, SecondActivity will start up.
            Intent resultIntent = new Intent(this, typeof(MainActivity));

            resultIntent.PutExtras(valuesForActivity);             // Pass some values to SecondActivity.

            Android.Support.V4.App.TaskStackBuilder stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(this);
            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            //Android.Net.Uri alarmSound = RingtoneManager.GetDefaultUri(RingtoneType.Notification);
            Android.Net.Uri alarmSound;             //= Android.Net.Uri.Parse ("android.resource://" + PackageName + "/" + Resource.Raw.noti_sound_coin);
            string          msgText;

            if (Ini.checkNotiId(notificationID))
            {
                alarmSound = Ini.DefaultNotiAudio;                //Ini.NotiAudioList [notificationID];
                msgText    = Ini.NotiTitleList [notificationID];
            }
            else
            {
                alarmSound = Ini.DefaultNotiAudio;
                msgText    = Ini.DefaultNotiTitle;
            }

            GF.devLog("[GcmService] notificationID: " + notificationID + "  msgText: " + msgText);

            // Build the notification
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                 .SetAutoCancel(true)                        // dismiss the notification from the notification area when the user clicks on it
                                                 .SetContentIntent(resultPendingIntent)      // start up this activity when the user clicks the intent.
                                                 .SetContentTitle(num.ToString() + msgText)  // Set the title
                                                 .SetSmallIcon(Resource.Drawable.Icon)       // This is the icon to display
                                                 .SetSound(alarmSound, 5)
                                                 .SetContentText(msg.Replace("</br>", " ")); // the message to display.
            //.SetContentInfo ("info")
            //.SetNumber (num); // Display the count in the Content Info

            // Finally publish the notification
            NotificationManager notificationManager = (NotificationManager)GetSystemService(NotificationService);

            notificationManager.Notify(notificationID, builder.Build());
        }
        void createNotification(string title, string desc, int id = 0)
        {
            // Pass the current button press count value to the next activity:
            Bundle valuesForActivity = new Bundle();

            valuesForActivity.PutInt("feedId", id);

            // When the user clicks the notification, SecondActivity will start up.
            Intent resultIntent = new Intent(this, typeof(MainActivity));

            // Pass some values to SecondActivity:
            resultIntent.PutExtras(valuesForActivity);

            // Construct a back stack for cross-task navigation:
            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);

            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            PendingIntent resultPendingIntent =
                stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            // vibration Pattern
            long[] pattern = { 500, 500, 500, 800, 500 };


            // Build the notification:
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                 .SetAutoCancel(true)                   // Dismiss from the notif. area when clicked
                                                 .SetContentIntent(resultPendingIntent) // Start 2nd activity when the intent is clicked.
                                                 .SetContentTitle(title)
                                                                                        //.SetNumber(777)                       // Display the count in the Content Info
                                                                                        //.SetLights( Color.BLUE, 500, 500)
                                                 .SetLights(global::Android.Graphics.Color.Blue, 300, 1000)

                                                 .SetVibrate(pattern)
                                                 .SetSmallIcon(Resource.Drawable.ic_launcher) // Display this icon
                                                 .SetTicker(desc)
                                                 .SetSound(GetNotificationSound(0))
                                                 .SetStyle(new NotificationCompat.BigTextStyle().BigText(desc))
                                                 .SetContentText(desc); // The message to display.


            // Finally, publish the notification:
            NotificationManager notificationManager =
                (NotificationManager)GetSystemService(Context.NotificationService);

            notificationManager.Notify(id, builder.Build());

            // Increment the button press count:
        }
        public void Notify(Intent intent)
        {
            var    rand              = new Random();
            var    randomNum         = rand.Next();
            Bundle valuesForActivity = new Bundle();

            valuesForActivity.PutInt("topicId", randomNum);

            Global.SetNotifTopic(intent.Extras.GetString("push_type"));
            Global.SetListTopic(randomNum, intent.Extras.GetString("push_type"));


            Intent resultIntent = new Intent(this, typeof(MainActivity));

            resultIntent.PutExtras(valuesForActivity);

            Android.Support.V4.App.TaskStackBuilder stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(this);
            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            PendingIntent resultPendingIntent =
                stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            var fullmessage = intent.Extras.GetString("message") + "\n" + intent.Extras.GetString("article_data");
            var imageBitmap = GetImageBitmapFromUrl(intent.Extras.GetString("image_url"));

            NotificationCompat.BigPictureStyle picstyle = new NotificationCompat.BigPictureStyle();
            picstyle.BigPicture(imageBitmap);

            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                 .SetAutoCancel(true)
                                                 .SetContentIntent(resultPendingIntent)
                                                 .SetContentTitle(intent.Extras.GetString("title"))
                                                 .SetNumber(Global.GetNotifCount())
                                                 .SetStyle(picstyle)
                                                 .SetSmallIcon(Resource.Drawable.UmbrellaArmyFavicon)
                                                 .SetContentText(String.Format(fullmessage));

            // Finally, publish the notification:
            NotificationManager notificationManager =
                (NotificationManager)GetSystemService(Context.NotificationService);

            notificationManager.Notify(ButtonClickNotificationId, builder.Build());

            if (Global.GetNotifTopic() != "general" || Global.GetNotifTopic() != "general_android")
            {
                var message = new StartLongRunningTaskMessage();
                MessagingCenter.Send(message, "StartLongRunningTaskMessage");
            }
        }
Пример #12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.LocalNotificationView);

            var txtMessage = FindViewById <EditText> (Resource.Id.txtMessage);
            var btnSend    = FindViewById <Button> (Resource.Id.btnSend);

            btnSend.Click += (object sender, EventArgs e) => {
                //
                Bundle valuesForActivity = new Bundle();
                valuesForActivity.PutString("message", txtMessage.Text);

                Intent resultIntent = new Intent(this, typeof(NotificationProcessingActivity));
                resultIntent.PutExtras(valuesForActivity);

                // Construct a back stack for cross-task navigation:
                TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);
                stackBuilder.AddParentStack(
                    Java.Lang.Class.FromType(typeof(NotificationProcessingActivity)));
                stackBuilder.AddNextIntent(resultIntent);

                // Create the PendingIntent with the back stack:
                PendingIntent resultPendingIntent =
                    stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);


                //

                NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                     .SetAutoCancel(true)                                  //
                                                     .SetContentIntent(resultPendingIntent)                // 使用者按下通知後,負責處理的 Activity
                                                     .SetContentTitle("Android Tips")                      // Title
                                                     .SetNumber(1)                                         // Display the count in the Content Info
                                                     .SetSmallIcon(Resource.Drawable.ic_stat_button_click) // Icon,必備
                                                     .SetContentText(txtMessage.Text);                     // 要顯示的訊息

                // 註冊系統服務
                NotificationManager notificationManager =
                    (NotificationManager)GetSystemService(Context.NotificationService);

                notificationManager.Notify(ButtonClickNotificationId, builder.Build());
            };
        }
        public override void OnReceive(Context context, Intent intent)
        {
            // Instanciamos
            _medicamento        = new Medicamento();
            _medicamentoService = new MedicamentoService();
            _medicamento        = _medicamentoService.selectMedicamento(); // Selecciona el medicamento

            if (_medicamento != null)
            {
                Intent newIntent = new Intent(context, typeof(MedicamentoAlert));

                // Agrega la siguiente tarea a la pila
                TaskStackBuilder stackBuilder = TaskStackBuilder.Create(context);
                stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MedicamentoAlert)));
                stackBuilder.AddNextIntent(newIntent);

                // Establecer la intencion que se abrira cuando un clic en la notificación
                PendingIntent notificationIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

                // Define bitmap para LargeIcon
                Bitmap bitmap = ((BitmapDrawable)ContextCompat.GetDrawable(context, Resource.Drawable.logo)).Bitmap;

                // Define sound
                Uri soundUri = RingtoneManager.GetDefaultUri(RingtoneType.Alarm);

                // Creamos la Notificacion
                var builder = new NotificationCompat.Builder(context)
                              .SetContentIntent(notificationIntent)
                              .SetSmallIcon(Resource.Drawable.logo)          // Icono pequeño
                              .SetLargeIcon(bitmap)                          // Icono grande
                              .SetContentTitle("Recordar Medicación")        // Titulo
                              .SetContentText("Ver detalles..")              // Contenido
                              .SetSound(soundUri)                            // Sonido
                              .SetVibrate(new long[] { 100, 250, 100, 500 }) // Vibración
                              .SetAutoCancel(true);

                // Mostrar Notificacion
                var manager = (NotificationManager)context.GetSystemService(Context.NotificationService);

                Random random       = new Random(); // id random para notificacion
                int    randomNumber = random.NextInt(9999 - 1000) + 1000;
                manager.Notify(randomNumber, builder.Build());
            }
        }
Пример #14
0
        /// <summary>
        /// Method to create a notification, requires activity components to build
        /// </summary>
        /// <param name="title"></param>
        /// <param name="text"></param>
        public void CreateNotification(string title, string text)
        {
            // Return if the app is running in the foreground as we do not want to create a notification
            if (!App.Minimised)
            {
                return;
            }

            PowerManager pm = (PowerManager)GetSystemService(Context.PowerService);

            PowerManager.WakeLock wakeLock = pm.NewWakeLock(WakeLockFlags.Partial, "BackgroundReceiver");
            wakeLock.Acquire();

            // When the user clicks the notification, SecondActivity will start up.
            Intent resultIntent = new Intent(this, typeof(MainActivity));


            // Construct a back stack for cross-task navigation:
            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);

            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            PendingIntent resultPendingIntent =
                stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            // Build the notification:
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                 .SetAutoCancel(true)                           // Dismiss from the notif. area when clicked
                                                 .SetContentIntent(resultPendingIntent)         // Start 2nd activity when the intent is clicked.
                                                 .SetContentTitle(title)                        // Set its title
                                                 .SetSmallIcon(Resource.Drawable.shopping_list) // Display this icon
                                                 .SetContentText(text);                         // The message to display.

            // Finally, publish the notification:
            NotificationManager notificationManager =
                (NotificationManager)GetSystemService(Context.NotificationService);

            notificationManager.Notify(1000, builder.Build());

            wakeLock.Release();
        }
Пример #15
0
        private void ButtonOnClick(object sender, EventArgs eventArgs)
        {
            // Pass the current button press count value to the next activity:
            Bundle valuesForActivity = new Bundle();

            valuesForActivity.PutInt("count", count);

            // When the user clicks the notification, SecondActivity will start up.
            Intent resultIntent = new Intent(this, typeof(SecondActivity));

            // Pass some values to SecondActivity:
            resultIntent.PutExtras(valuesForActivity);

            // Construct a back stack for cross-task navigation:
            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);

            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(SecondActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            PendingIntent resultPendingIntent =
                stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            // Build the notification:
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                 .SetAutoCancel(true)                                                   // Dismiss from the notif. area when clicked
                                                 .SetContentIntent(resultPendingIntent)                                 // Start 2nd activity when the intent is clicked.
                                                 .SetContentTitle("Button Clicked")                                     // Set its title
                                                 .SetNumber(count)                                                      // Display the count in the Content Info
                                                 .SetSmallIcon(Resource.Drawable.ic_stat_button_click)                  // Display this icon
                                                 .SetContentText(String.Format(
                                                                     "The button has been clicked {0} times.", count)); // The message to display.

            // Finally, publish the notification:
            NotificationManager notificationManager =
                (NotificationManager)GetSystemService(Context.NotificationService);

            notificationManager.Notify(ButtonClickNotificationId, builder.Build());

            // Increment the button press count:
            count++;
        }
Пример #16
0
        private void _dialogService_NotificateIt(object sender, NotificaiosModel notification)
        {
            // Pass the current button press count value to the next activity:
            Bundle valuesForActivity = new Bundle();


            // When the user clicks the notification, SecondActivity will start up.
            Intent resultIntent = new Intent(this, typeof(MainActivity));

            // Pass some values to SecondActivity:
            resultIntent.PutExtras(valuesForActivity);

            // Construct a back stack for cross-task navigation:
            Android.Support.V4.App.TaskStackBuilder stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(this);
            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            PendingIntent resultPendingIntent =
                stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            // Build the notification:
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)

                                                 .SetAutoCancel(true)                 // Dismiss from the notif. area when clicked
                                                                                      //       .SetContentIntent(resultPendingIntent)  // Start 2nd activity when the intent is clicked.
                                                 .SetContentTitle(notification.title) // Set its title
//                .SetNumber(10)                       // Display the count in the Content Info
                                                 .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
                                                 .SetSmallIcon(Resource.Drawable.logo)
                                                 .SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.logo))
                                                 .SetPriority(1)
                                                 .SetVisibility(5)
                                                 .SetVibrate(new long[] { 500, 500 })
                                                 .SetContentText(notification.description); // The message to display.

            // Finally, publish the notification:
            NotificationManager notificationManager =
                (NotificationManager)GetSystemService(Context.NotificationService);

            notificationManager.Notify(++ButtonClickNotificationId, builder.Build());
        }
Пример #17
0
        private static void NotifyHeartRate(Context context, user_page userPage, int HR, HRStatus status)
        {
            // When the user clicks the notification, SecondActivity will start up.
            Intent resultIntent = new Intent(userPage, typeof(NotificationActivity));

            // Passing HR and HRStatus to notification activity
            Bundle valuesForActivity = new Bundle();

            valuesForActivity.PutInt("status", (int)status);
            valuesForActivity.PutInt("HR", HR);
            resultIntent.PutExtras(valuesForActivity);

            // Construct a back stack for cross-task navigation:
            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(context);

            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(NotificationActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            PendingIntent resultPendingIntent =
                stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent | (int)PendingIntentFlags.OneShot);

            // Build the notification:
            NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                                                 .SetAutoCancel(true)                              // Dismiss from the notif. area when clicked
                                                 .SetContentIntent(resultPendingIntent)            // Start 2nd activity when the intent is clicked.
                                                 .SetContentTitle("Is everything OK?")             // Set its title
                                                 .SetNumber(HR)                                    // Display the HR in the Content Info
                                                 .SetSmallIcon(Resource.Drawable.emptyheart_white) // Display this icon
                                                 .SetContentText(string.Format(
                                                                     "Your heart beat {0} to {1} bpm.",
                                                                     status == HRStatus.Hypo ? "decreased dramaticaly" :
                                                                     status == HRStatus.Hyper ? "increased dramaticaly" :
                                                                     "is not stable and changed dramatically", HR)); // The message to display.

            // Finally, publish the notification:
            NotificationManager notificationManager =
                (NotificationManager)context.GetSystemService(Context.NotificationService);

            notificationManager.Notify(ButtonClickNotificationId, builder.Build());
        }
Пример #18
0
        void ButtonOnClick(object sender, EventArgs eventArgs)
        {
            // Pass the current button press count value to the next activity:
            var valuesForActivity = new Bundle();

            valuesForActivity.PutInt(COUNT_KEY, count);

            // When the user clicks the notification, SecondActivity will start up.
            var resultIntent = new Intent(this, typeof(LocalNotifications.SecondActivity));

            // Pass some values to SecondActivity:
            resultIntent.PutExtras(valuesForActivity);

            // Construct a back stack for cross-task navigation:
            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);

            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(LocalNotifications.SecondActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            var resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            // Build the notification:
            var builder = new NotificationCompat.Builder(this, CHANNEL_ID)
                          .SetAutoCancel(true)                                            // Dismiss the notification from the notification area when the user clicks on it
                          .SetContentIntent(resultPendingIntent)                          // Start up this activity when the user clicks the intent.
                          .SetContentTitle("Button Clicked")                              // Set the title
                          .SetSmallIcon(Resource.Drawable.ic_stat_button_click)
                          .SetNumber(count)                                               // Display the count in the Content Info
                          .SetContentText($"The button has been clicked {count} times."); // the message to display.

            // Finally, publish the notification:
            var notificationManager = NotificationManagerCompat.From(this);

            notificationManager.Notify(NOTIFICATION_ID, builder.Build());

            // Increment the button press count:
            count++;
        }
Пример #19
0
        public void VerificaNotificacao()
        {
            //Thread.CurrentThread.Name = "verifica";
            Thread t1 = new Thread(new ThreadStart(run));

            t1.Start();

            void run()
            {
                TimeSpan comeco = new TimeSpan(14, 40, 00); //Define inicio do disparo da thread 00:00:00
                TimeSpan fim    = new TimeSpan(15, 32, 00); //Define o fim do intervalo da thread
                TimeSpan agora  = DateTime.Now.TimeOfDay;   //Obtem a horario atual

                if ((agora >= comeco) && (agora < fim))     // condicao para exibir a notificacao dentro do intervalo definido
                {
                    Bundle valueSend = new Bundle();
                    valueSend.PutString("sendContent", "Teste Sucesso"); //Destino do tapped da notificação

                    Intent newIntent = new Intent(this, typeof(Second_Activity));
                    newIntent.PutExtras(valueSend);

                    Android.Support.V4.App.TaskStackBuilder stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(this);
                    stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(Second_Activity)));
                    stackBuilder.AddNextIntent(newIntent);

                    PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

                    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                         .SetAutoCancel(true)
                                                         .SetContentIntent(resultPendingIntent)
                                                         .SetContentTitle("SESC TREINO")                         // Define titulo da notificação;
                                                         .SetSmallIcon(Resource.Drawable.icon)                   //Define ícone da notificacao;
                                                         .SetContentText("Você tem um novo aviso. Clique aqui"); // Texto da notificação

                    NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
                    notificationManager.Notify(ButtonClickNotification, builder.Build());
                }
            }
        }
Пример #20
0
        public override void OnReceive(Context context, Intent intent)
        {
            // When the user clicks the notification, MainActivity will start up.
            Intent resultIntent = new Intent(context, typeof(MainActivity));

            // Construct a back stack for cross-task navigation:
            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(context);

            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            PendingIntent resultPendingIntent =
                stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);


            DateTime thisDay        = DateTime.Today;
            bool     lastDayOfMonth = (thisDay.Day == DateTime.DaysInMonth(thisDay.Year, thisDay.Month));
            string   notificationText;

            notificationText = "Fyll i!";
            if (lastDayOfMonth)
            {
                notificationText = "Fyll i och skicka iväg!";
            }

            NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "reminder_notification");
            builder.SetAutoCancel(true)
            .SetDefaults((int)NotificationDefaults.All)
            .SetContentIntent(resultPendingIntent)
            .SetSmallIcon(Resource.Drawable.Icon)
            .SetContentTitle("Motivationskalender")
            .SetSmallIcon(Resource.Drawable.ic_launcher)
            .SetContentText(notificationText);

            NotificationManager manager = (NotificationManager)context.GetSystemService(Context.NotificationService);

            manager.Notify(1, builder.Build());
        }
Пример #21
0
        public override void OnReceive(Context context, Intent intent)
        {
            //getting the data passed
            var message = intent.Extras.GetString("message", "yo");

            //Notification intent
            var notIntent = new Intent(context, typeof(SecondActivity));


            //creating the bundle, adding data and adding to the notification intent
            Bundle ValuesForActivity = new Bundle();

            ValuesForActivity.PutString("message", message);
            notIntent.PutExtras(ValuesForActivity);

            //Create the TaskStackBuilder for cross app navigation
            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(context);

            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(SecondActivity)));
            stackBuilder.AddNextIntent(notIntent);
            PendingIntent contentIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            //Create the notification manager
            var manager = NotificationManagerCompat.From(context);

            // Build the notification
            NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                                                 .SetAutoCancel(true)                                                     // Dismiss from the notif. area when clicked
                                                 .SetContentIntent(contentIntent)                                         // Start 2nd activity when the intent is clicked.
                                                 .SetContentTitle("Button Clicked")                                       // Set its title                    // Display the count in the Content Info
                                                 .SetSmallIcon(Resource.Drawable.ic_stat_button_click)                    // Display this icon
                                                 .SetContentText(String.Format(
                                                                     "The button has been clicked {0} times.", message)); // The message to display.

            // Finally, publish the notification:
            var notification = builder.Build();

            manager.Notify(0, notification);
        }
Пример #22
0
        public void DisplayNotification(string message)
        {
            int notificationId = 1000;

            Intent resultIntent = new Intent(this, typeof(MainActivity));

            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);

            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            PendingIntent resultPendingIntent =
                stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            // Pass the current button press count value to the next activity:
            Bundle valuesForActivity = new Bundle();

            // Build the notification:
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                 .SetAutoCancel(false)             // Dismiss from the notif. area when clicked
                                                 .SetContentIntent(resultPendingIntent)
                                                 .SetContentTitle("Content Title") // Set its title
                                                 .SetContentText("Content Text")
                                                 .SetContentInfo("Content Info")
                                                 .SetOngoing(true)
                                                 .SetSmallIcon(Resource.Drawable.notification_icon_background)
                                                 .SetContentText(message); // The message to display.


            // Finally, publish the notification:
            //NotificationManager notificationManager =
            //    (NotificationManager)GetSystemService(Context.NotificationService);
            //notificationManager.Notify(ButtonClickNotificationId, builder.Build());

            StartForeground(notificationId, builder.Build());

            // Increment the button press count:
        }
Пример #23
0
        void Notification(int resource)
        {
            Intent resultIntent = new Intent(this, typeof(MainActivity));

            Android.Support.V4.App.TaskStackBuilder stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(this);
            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);
            string        myTitle, myContent;

            if (resource == 0)
            {
                myTitle   = "Need Water";
                myContent = "Need Water";
            }
            else if (resource == 1)
            {
                myTitle   = "Need food";
                myContent = "Need Food";
            }
            else
            {
                myTitle   = "Morreu";
                myContent = "Morreu";
            }

            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                 .SetAutoCancel(true)
                                                 .SetDefaults((int)NotificationDefaults.Sound)
                                                 .SetContentIntent(resultPendingIntent)
                                                 .SetContentTitle(myTitle)
                                                 .SetContentText(myContent);

            NotificationManager nf = (NotificationManager)this.GetSystemService(Context.NotificationService);

            nf.Notify(1000, builder.Build());
        }
Пример #24
0
        void SendNotification(string message)
        {
            Bundle valuesForActivity = new Bundle();

            valuesForActivity.PutString("message", message);

            Intent resultIntent = new Intent(this, typeof(NotificationProcessingActivity));

            resultIntent.PutExtras(valuesForActivity);

            // Construct a back stack for cross-task navigation:
            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);

            stackBuilder.AddParentStack(
                Java.Lang.Class.FromType(typeof(NotificationProcessingActivity)));
            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            PendingIntent resultPendingIntent =
                stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);



            var notificationBuilder = new NotificationCompat.Builder(this)
                                      .SetSmallIcon(Resource.Drawable.ic_stat_button_click)
                                      .SetContentTitle("GCM Message")
                                      .SetContentText(message)
                                      .SetAutoCancel(true)
                                      //.SetVibrate(vT) //设置震动,此震动数组为:long vT[]={300,100,300,100}; 还可以设置灯光.setLights(argb, onMs, offMs)
                                      .SetOngoing(true)
                                      .SetContentIntent(resultPendingIntent);

            var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);

            notificationManager.Notify(0, notificationBuilder.Build());
        }
Пример #25
0
        private void LocalPushNotification(String name)
        {
            //String local_name = getName;
            String chumma    = name;
            Bundle valueSend = new Bundle();

            valueSend.PutString("sendContent", "Something has to be done");

            Intent newIntent = new Intent(this, typeof(SecondActivity));

            newIntent.PutExtras(valueSend);

            Android.Support.V4.App.TaskStackBuilder stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(this);
            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(SecondActivity)));
            stackBuilder.AddNextIntent(newIntent);

            PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                 .SetAutoCancel(true)
                                                 .SetContentIntent(resultPendingIntent)
                                                 .SetContentTitle("Remainding You!!!")
                                                 .SetSmallIcon(Resource.Drawable.ic_stat_button_click)
                                                 .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
                                                 .SetContentText("You have to Receive payment from" + " " + chumma);


            NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);

            notificationManager.Notify(LocalNotification1, builder.Build());
            //Implementing the Alarm Service from Here
            String   message = "You have some task to look after";
            DateTime now     = DateTime.Now.ToLocalTime();

            RemaindingService(now, chumma, message);
        }
Пример #26
0
        public override void OnReceive(Context context, Intent intent)
        {
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context);

            String medicineName = prefs.GetString("medicineName", "");
            int    ringtoneidnr = prefs.GetInt("ringtoneidnr", 1);



            // Pass the current button press count value to the next activity:
            //Bundle valuesForActivity = new Bundle();
            //valuesForActivity.PutInt("count", count);
            //valuesForActivity.PutString("name", "Rose");

            ISharedPreferencesEditor editor = prefs.Edit();

            editor.PutInt("count", count);
            editor.PutString("name", "Rose");
            editor.Apply();

            Intent resultIntent = new Intent(context, typeof(MeldingErna));

            // Pass some values to SecondActivity:
            // resultIntent.PutExtras(valuesForActivity);
            count++;

            // Construct a back stack for cross-task navigation:
            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(context);

            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MeldingErna)));
            stackBuilder.AddNextIntent(resultIntent);

            // Create the PendingIntent with the back stack:
            PendingIntent resultPendingIntent =
                stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);



            long[] vibrate = new long[] { 1000, 1000, 1000, 1000, 1000 };
            //Android.Net.Uri uri = Android.Net.Uri.Parse("android.resource://" + context.PackageName + "/"
            //                    + Resource.Raw.ialarm);

            // Build the notification: This is required to show notification
            NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                                                 .SetAutoCancel(true)                                                   // Dismiss from the notif. area when clicked
                                                 .SetContentIntent(resultPendingIntent)                                 // Start 2nd activity when the intent is clicked.
                                                 .SetContentTitle("Alarm :" + medicineName)                             // Set its title
                                                 .SetVibrate(vibrate)
                                                                                                                        //.SetSound(uri)
                                                 .SetNumber(count)                                                      // Display the count in the Content Info
                                                 .SetSmallIcon(Resource.Drawable.Icon)                                  // Display this icon
                                                 .SetContentText(String.Format(
                                                                     "The button has been clicked {0} times.", count)); // The message to display.
                                                                                                                        //throw new NotImplementedException();
            if (ringtoneidnr == 1)
            {
                Android.Net.Uri uri = Android.Net.Uri.Parse("android.resource://" + context.PackageName + "/"
                                                            + Resource.Raw.ialarm);
                builder.SetSound(uri);
            }
            else if (ringtoneidnr == 2)
            {
                Android.Net.Uri seconduri = Android.Net.Uri.Parse("android.resource://" + context.PackageName + "/"
                                                                  + Resource.Raw.radar);
                builder.SetSound(seconduri);
            }
            else if (ringtoneidnr == 3)
            {
                Android.Net.Uri thirduri = Android.Net.Uri.Parse("android.resource://" + context.PackageName + "/"
                                                                 + Resource.Raw.sunalarm);
                builder.SetSound(thirduri);
            }

            NotificationManager notificationManager =
                (NotificationManager)context.GetSystemService(Context.NotificationService);

            notificationManager.Notify(ButtonClickNotificationId, builder.Build());
        }
Пример #27
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.main);

            Button botaoAdd     = FindViewById <Button>(Resource.Id.botaoAdd);
            Button botaoExcluir = FindViewById <Button>(Resource.Id.botaoExcluir);

            lista            = FindViewById <ListView>(Resource.Id.listaTarefas);
            lista.ChoiceMode = ChoiceMode.Single;

            if (Tarefa.listaTarefas == null)
            {
                listaTarefas = new List <Tarefa>();
            }
            else
            {
                listaTarefas = Tarefa.listaTarefas;
                nomes        = nomesTarefas(listaTarefas);
                enviarMensagem(listaTarefas);
            }

            adapter       = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItemSingleChoice, nomesTarefas(listaTarefas));
            lista.Adapter = adapter;

            lista.ItemLongClick += delegate {
                AlertDialog.Builder caixa = new AlertDialog.Builder(this);
                caixa.SetTitle("Descrição");
                caixa.SetMessage("Teste");
                caixa.SetPositiveButton("OK", (sender, args) =>
                {
                });
                caixa.Show();
            };

            try
            {
                bool enviado = Intent.Extras.GetBoolean("enviado");
                if (enviado)
                {
                    CheckarItem();
                }
            }
            catch (Exception ex) {
            }

            botaoAdd.Click += delegate
            {
                StartActivity(typeof(AddTarefa));
            };

            botaoExcluir.Click += delegate
            {
                var posicao = lista.CheckedItemPosition;
                if (lista.CheckedItemCount != 0)
                {
                    excluirTarefa(posicao);
                }
                else
                {
                    AlertDialog.Builder caixa = new AlertDialog.Builder(this);
                    caixa.SetTitle("Excluir Tarefa");
                    caixa.SetMessage("Selecione uma tarefa");
                    caixa.SetPositiveButton("OK", (sender, args) =>
                    {
                    });
                    caixa.Show();
                }
            };

            List <string> nomesTarefas(List <Tarefa> tarefas)
            {
                List <string> nomes = new List <string>();

                foreach (Tarefa tarefa in tarefas)
                {
                    nomes.Add(tarefa.nomeTarefa + " (" + tarefa.dataTarefa + ")");
                }
                return(nomes);
            }

            void CheckarItem()
            {
                for (int i = 0; i < lista.Count; i++)
                {
                    if (lista.GetItemAtPosition(i).ToString().Contains(DateTime.Now.ToString("dd/MM/yyyy")))
                    {
                        lista.SetItemChecked(i, true);
                    }
                }
            }

            void excluirTarefa(int posicao)
            {
                AlertDialog.Builder caixa = new AlertDialog.Builder(this);
                caixa.SetTitle("Excluir Tarefa");
                caixa.SetCancelable(true);
                caixa.SetMessage("Deseja excluir a tarefa?");
                caixa.SetPositiveButton("Excluir", (sender, args) =>
                {
                    Tarefa.listaTarefas.RemoveAt(posicao);
                    StartActivity(typeof(Main));
                });
                caixa.Show();
            }

            void enviarMensagem(List <Tarefa> tarefas)
            {
                foreach (Tarefa tarefa in tarefas)
                {
                    if (tarefa.dataTarefa.Equals(DateTime.Now.ToString("dd/MM/yyyy")))
                    {
                        enviarNotificacao();
                    }
                }
            }

            void enviarNotificacao()
            {
                Intent migrar = new Intent(this, typeof(Main));

                migrar.PutExtra("enviado", true);
                Android.Support.V4.App.TaskStackBuilder stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(this);
                stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(Main)));
                stackBuilder.AddNextIntent(migrar);

                PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

                NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                     .SetAutoCancel(true)
                                                     .SetContentIntent(resultPendingIntent)
                                                     .SetContentTitle("Dia da tarefa")
                                                     .SetSmallIcon(Resource.Mipmap.ic_launcher)
                                                     .SetContentText("O dia da sua tarefa chegou! Clique para vê-la!");

                NotificationManager notificationManager =
                    (NotificationManager)GetSystemService(Context.NotificationService);

                notificationManager.Notify(botaoNotificacao, builder.Build());
            }
        }
Пример #28
0
        public void CreateNotification(int notificationType, int notificationId)
        {
            string notificationTitle = "";
            string notificationMsg   = "";

            NotificationCompat.Builder builder = new NotificationCompat.Builder(Forms.Context);

            // Checked In Notification
            if (notificationType == NOTIFICATION_TYPE_USER_CHECKED_IN)
            {
                notificationTitle = Txt.NOTIFICATION_TITLE_CHECKED_IN;
                notificationMsg   = Txt.NOTIFICATION_TITLE_CHECKED_IN;

                // Create an Intent to open the main activity, if there is an existing activity it must be killed and
                // for the new activity to take place
                Intent resultIntent = new Intent(Forms.Context, typeof(MainActivity));
                resultIntent.PutExtra(AndroidMethods.PARAM_SELECTED_LOCATION_ID, App.checkedInLocationID);
                resultIntent.PutExtra(AndroidMethods.PARAM_LAST_SESSION_PID, Android.OS.Process.MyPid());
                resultIntent.AddFlags(ActivityFlags.SingleTop);

                // Construct a back stack for cross-task navigation
                TaskStackBuilder stackBuilder = TaskStackBuilder.Create(Forms.Context);
                stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
                stackBuilder.AddNextIntent(resultIntent);

                // Create the PendingIntent with the back stack
                PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

                builder.SetContentTitle(notificationTitle)                     // Notification title
                .SetContentText(notificationMsg)                               // Notification message
                .SetSmallIcon(Resource.Drawable.ico_alert)                     // Notification icon
                .SetAutoCancel(true)                                           // Dismiss from the notif. area when clicked
                .SetContentIntent(resultPendingIntent)                         // Start 2nd activity when the intent is clicked.
                .SetNumber(1);                                                 // Display the count in the Content Info

                // Checked Out Notification
            }
            else if (notificationType == NOTIFICATION_TYPE_USER_CHECKED_OUT)
            {
                notificationTitle = Txt.NOTIFICATION_TITLE_CHECKED_OUT;
                notificationMsg   = Txt.NOTIFICATION_BODY_CHECKED_OUT;

                builder.SetContentTitle(notificationTitle)                     // Notification title
                .SetContentText(notificationMsg)                               // Notification message
                .SetSmallIcon(Resource.Drawable.ico_alert)                     // Notification icon
                .SetAutoCancel(true)                                           // Dismiss from the notif. area when clicked
                .SetNumber(1);                                                 // Display the count in the Content Info

                // Welcome Back Notification
            }
            else if (notificationType == NOTIFICATION_TYPE_WELCOME_BACK)
            {
                notificationTitle = Txt.NOTIFICATION_TITLE_WELCOME_BACK;
                notificationMsg   = Txt.NOTIFICATION_BODY_WELCOME_BACK;

                builder.SetContentTitle(notificationTitle)                     // Notification title
                .SetContentText(notificationMsg)                               // Notification message
                .SetSmallIcon(Resource.Drawable.ico_alert)                     // Notification icon
                .SetAutoCancel(true)                                           // Dismiss from the notif. area when clicked
                .SetNumber(1);                                                 // Display the count in the Content Info
            }

            NotificationManager notificationManager = (NotificationManager)Forms.Context.GetSystemService(
                Context.NotificationService
                );

            notificationManager.Notify(notificationId, builder.Build());
        }
Пример #29
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Window.RequestFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.PageMainStart);

            InitFields();

            if (LoginActivity.StaticLocationClass.Name != null)
            {
                int i;
                mStorages.Count();
                mCurrentLocation.Text = LoginActivity.StaticLocationClass.Name;
                for (i = 0; mStorages.Count() > i; i++)
                {
                    int mCounter = 0;
                    if (mStorages[i].Id == LoginActivity.StaticLocationClass.Id)
                    {
                        for (int j = 0; mInventories.Count > j; j++)
                        {
                            if (mInventories[j].Id == mStorages[i].Id)
                            {
                                mCounter++;
                                mStockCounter.Text = mCounter.ToString();
                            }
                        }
                    }
                }
                mExpCounter.Text = "0";

                mRunOutCounter.Text = "0";
            }
            #region shortcut menu
            mRunOut.Click += (object sender, EventArgs args) =>
            {
                Intent nextActivity = new Intent(this, typeof(UseActivity));
                StartActivity(nextActivity);
            };
            mShopList.Click += (object sender, EventArgs args) =>
            {
                Intent nextActivity = new Intent(this, typeof(DrawerMenuActivity));
                StartActivity(nextActivity);
            };
            mAdd.Click += (object sender, EventArgs args) =>
            {
                Intent nextActivity = new Intent(this, typeof(ItemAddFormActivity));
                StartActivity(nextActivity);
            };
            mUse.Click += (object sender, EventArgs args) =>
            {
                Intent nextActivity = new Intent(this, typeof(UseActivity));
                StartActivity(nextActivity);
            };
            mStoragesMenu.Click += (object sender, EventArgs args) =>
            {
                Intent nextActivity = new Intent(this, typeof(StoragesActivity));
                StartActivity(nextActivity);
            };

            btnSend.Click += (s, e) =>
            {
                Bundle valuesSend = new Bundle();
                valuesSend.PutString("sendContent", "This is content awdawda");
                Intent newIntent = new Intent(this, typeof(UseActivity));
                newIntent.PutExtras(valuesSend);

                Android.Support.V4.App.TaskStackBuilder stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(this);
                stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(UseActivity)));
                stackBuilder.AddNextIntent(newIntent);
                PendingIntent resultPendingIntent  = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);
                NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                     .SetAutoCancel(true)
                                                     .SetContentIntent(resultPendingIntent)
                                                     .SetContentTitle("You have new Notification")
                                                     .SetSmallIcon(Resource.Drawable.logoshopdiary)
                                                     .SetContentText("You have expired items");

                NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
                notificationManager.Notify(ButtonClickNotification, builder.Build());
            };

            mBtnThreeStrips.Click += (object sender, EventArgs args) =>
            {
                Intent nextActivity = new Intent(this, typeof(DrawerMenuActivity));
                StartActivity(nextActivity);
            };
            #endregion
        }
Пример #30
0
        private void verificaMensagem()
        {
            _timer = new System.Threading.Timer((o) => {
                var webservice = new WS.IdmServerservice(MainActivity.sCaminhoWS.ToString());

                arCarregaMensagem = webservice.BeginCarregaMensagem(MainActivity.iCodEmpresa.ToString(), null, webservice);

                resultadoMensagem = "";
                resultadoMensagem = webservice.EndCarregaMensagem(arCarregaMensagem);

                //ao enviar um item para a caixa, verificar se a mesa ja não foi fechada
                if (resultadoMensagem != "erro")
                {
                    int i;
                    int j;
                    string temp;
                    string letra;

                    string codEmpresa;
                    string codMensagem;
                    string titulo;
                    string subtitulo;
                    string mensagem;
                    string data;

                    i     = resultadoMensagem.Length;
                    j     = 0;
                    temp  = "";
                    letra = "";

                    codEmpresa  = "";
                    codMensagem = "";
                    titulo      = "";
                    subtitulo   = "";
                    mensagem    = "";
                    data        = "";

                    while (j < i)
                    {
                        letra = resultadoMensagem [j].ToString();

                        if (letra != "|" & letra != "%")
                        {
                            temp = temp + letra;
                        }

                        if (letra == "|")
                        {
                            if (codEmpresa == "")
                            {
                                codEmpresa = temp;
                            }
                            else if (codMensagem == "")
                            {
                                codMensagem = temp;
                            }
                            else if (titulo == "")
                            {
                                titulo = temp;
                            }
                            else if (mensagem == "")
                            {
                                mensagem = temp;
                            }
                            else if (data == "")
                            {
                                data = temp;
                            }
                            else if (subtitulo == "")
                            {
                                subtitulo = temp;
                            }

                            temp = "";
                        }

                        if (letra == "%")
                        {
                            sql_cursor = sqldb_mensagem.GetRecordCursor(MainActivity.iCodEmpresa, Convert.ToInt32(codMensagem));

                            if (sql_cursor.Count == 0)
                            {
                                lsMensagens.Add(insMensagem(Convert.ToInt32(codEmpresa), Convert.ToInt32(codMensagem), titulo, mensagem, data, subtitulo));

                                sqldb_mensagem.AddRecord(Convert.ToInt32(codEmpresa), Convert.ToInt32(codMensagem), titulo, mensagem, data, subtitulo);

                                //NOTIFICACAO DE MENSAGEM

                                Bundle valuesForActivity = new Bundle();
                                valuesForActivity.PutInt("count", Convert.ToInt32(codMensagem));

                                // Create the PendingIntent with the back stack
                                // When the user clicks the notification, SecondActivity will start up.
                                Intent resultIntent = new Intent(this, typeof(Mensagem));
                                resultIntent.PutExtras(valuesForActivity);                                  // Pass some values to SecondActivity.

                                Android.Support.V4.App.TaskStackBuilder stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(this);
                                stackBuilder.AddParentStack(Class.FromType(typeof(Mensagem)));
                                stackBuilder.AddNextIntent(resultIntent);

                                PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

                                // Build the notification
                                NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                                     .SetAutoCancel(true)                                  // dismiss the notification from the notification area when the user clicks on it
                                                                     .SetContentIntent(resultPendingIntent)                // start up this activity when the user clicks the intent.
                                                                     .SetContentTitle(titulo)                              // Set the title
                                                                     .SetNumber(Convert.ToInt32(codMensagem))              // Display the count in the Content Info
                                                                     .SetSmallIcon(Resource.Drawable.ic_stat_button_click) // This is the icon to display
                                                                     .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
                                                                     .SetContentText(subtitulo);                           // the message to display.

                                //long[] pattern = {200,500};
                                //builder.SetVibrate(pattern);

                                // Finally publish the notification
                                NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
                                notificationManager.Notify(ButtonClickNotificationId, builder.Build());

                                MainActivity.sMensagem = mensagem;
                            }

                            temp = "";

                            codEmpresa  = "";
                            codMensagem = "";
                            titulo      = "";
                            subtitulo   = "";
                            mensagem    = "";
                            data        = "";
                        }
                        j++;
                    }
                }
            }, null, 0, 60000 * 2);             //60.000 = 1 minuto
        }