我试图在# Redirect old file path to new file path
Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html
的预定时间内发出警报通知,但警报仅在我启动应用程序时通知,为什么会这样
以下是实施警报类的方法:
Sqlite
现在,当您查看上面的代码时,我会从
public class AlarmImplementation { public AlarmImplementation() { } public async void MakeAlarm() { MedicationDatabase db = new MedicationDatabase(); //This method has the list of time in Sqlite var alarm_list = db.GetAlarmList(); //Debug.WriteLine(" Time -- : "+ m.ToString()); var message = "Hello Its me new one "; var title = "Diabetics App"; //looping time from Sqlite foreach (var list in alarm_list) { var hour = Int32.Parse(list.Substring(0, 2)); var minute = Int32.Parse(list.Substring(3, 2)); Debug.WriteLine("Hour : " + hour + "\n"); Debug.WriteLine("Minute " + minute + "\n"); Intent myintent = new Intent(Xamarin.Forms.Forms.Context, typeof(AlarmReceiver)); myintent.PutExtra("message", message); myintent.PutExtra("title", title); PendingIntent pendingintent = PendingIntent.GetBroadcast(Xamarin.Forms.Forms.Context, 0, myintent, PendingIntentFlags.UpdateCurrent); Java.Util.Date date = new Java.Util.Date(); Java.Util.Calendar cal = Java.Util.Calendar.Instance; cal.TimeInMillis = Java.Lang.JavaSystem.CurrentTimeMillis(); cal.Set(Java.Util.CalendarField.HourOfDay, hour); cal.Set(Java.Util.CalendarField.Minute, minute); cal.Set(Java.Util.CalendarField.Second, 0); // PendingIntent pendingIntent = PendingIntent.GetBroadcast(this, 0, alarmIntent, PendingIntentFlags.UpdateCurrent); AlarmManager alarmManager = Xamarin.Forms.Forms.Context.GetSystemService(Android.Content.Context.AlarmService) as AlarmManager; alarmManager.Set(AlarmType.RtcWakeup, cal.TimeInMillis, pendingintent); } } }
获得时间 我将其连接到Sqlite
。然后在下面的代码中,我想我在中调用
AlarmManager
方法 MainActivity。
这是我的 MainActivity 类:
MakeAlarm
我的问题是如何在预定时间发出警报通知 没有按下按钮,因为我有时间在Sqlite。