【发布时间】:2021-09-24 17:06:56
【问题描述】:
一段时间以来,他一直试图在应用程序中为给定的日期和月份设置通知。不幸的是,通知会在每天调用它几秒钟后出现。
这是我的代码:
private void Remind_Click(object sender, System.EventArgs e)
{
string title = "If you see this";
string message = "it means it works";
Intent alarmIntent = new Intent(Application.Context, typeof(AlarmReceiver));
alarmIntent.PutExtra("message", message);
alarmIntent.PutExtra("title", title);
var pendingIntent = PendingIntent.GetBroadcast(this, 0, alarmIntent, PendingIntentFlags.UpdateCurrent);
var alarmManager = GetSystemService(AlarmService).JavaCast<AlarmManager>();
DateTime nowDate = DateTime.Now;
int month = 09;
int day = 24;
DateTime newDate = new DateTime(nowDate.Year, month, day);
DateTime date = newDate;
var ms = (long)(date - new DateTime(1970, 1, 1)).TotalMilliseconds;
alarmManager.SetInexactRepeating(AlarmType.RtcWakeup, 3600000, ms, pendingIntent);
ShowSnack(main, $"Set date: {date} ");
}
请帮我解决这个问题。
【问题讨论】:
标签: android xamarin notifications