Ejemplo n.º 1
0
        protected static void SendNotify(Context context, string washDayId, string title, string content)
        {
            try
            {
                // When the user clicks the notification, SecondActivity will start up.
                var resultIntent = new Intent(context, typeof(MainActivity));

                var p = PendingIntent.GetActivity(context, DateTime.Now.Millisecond, resultIntent, PendingIntentFlags.UpdateCurrent);


                // Build the notification:
                var builder = new NotificationCompat.Builder(context, CHANNEL_ID)
                              .SetAutoCancel(true)                  // Dismiss the notification from the notification area when the user clicks on it
                              .SetContentTitle(title)               // Set the title
                              .SetContentIntent(p)                  // Start up this activity when the user clicks the intent.
                              .SetNumber(1)                         // Display the count in the Content Info
                              .SetSmallIcon(Resource.Drawable.icon) // This is the icon to display
                              .SetContentText(content)
                              .SetLargeIcon(BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.icon))
                ;               // the message to display.


                // Finally, publish the notification:
                var notificationManager = NotificationManagerCompat.From(context);
                notificationManager.Notify(DateTime.Now.Millisecond, builder.Build());
            }
            catch (Exception e)
            {
                AndroidLog.WriteLog($"Error during creation of Alarm Reminder Receiver: {e.StackTrace}");
            }
        }
Ejemplo n.º 2
0
        public override Result DoWork()
        {
            AndroidLog.WriteLog("Alarmworker works");

            var currentHour = DateTime.Now.Hour;

            if (currentHour >= 6)
            {
                AndroidLog.WriteLog("It is past 6");
                new AlarmNotify().Notify(mContext);
            }

            if (currentHour >= 14)
            {
                AndroidLog.WriteLog("It is past 14");
                new ReminderNotfiy().Notify(mContext);
            }
            return(Result.InvokeSuccess());
        }
Ejemplo n.º 3
0
 public AlarmWorker(Context c, WorkerParameters p) : base(c, p)
 {
     AndroidLog.WriteLog("Alarmworker initialized");
     mContext = c;
 }