windows-phone-7windows-phone-7.1

alarm functionality in Windows Phone 7?


I am saving the time in sqlite database. There are five screens in my app. In first screen I am adding the details including time in sqlite database. In second screen I am getting the details from sqlite database showing the details to user. In that page I wrote alarm functionality given alarm.Begintime=sqlitestoreddatetimevalue; if user as in the same page then only firing alarm. If user closes the app the alarm didn't work. How to achieve this?

Where to write alarm functionality to call through out application.time data coming from sqlitee database.


Solution

  • You need to add the alarm to the ScheduledActionService in order to register the alarm with the system, so that it goes off.

    Assuming alarmTime is the variable which stores the time at which the alarm should go off, do the following:

    var alarm = new Microsoft.Phone.Scheduler.Alarm(System.Guid.NewGuid().ToString())
                {
                    Content = "Alarm Text",
                    BeginTime = alarmTime,
                    Sound = new Uri("Location of Sound file which the alarm will use when triggered", UriKind.Relative),
                    //RecurrenceType = RecurrenceInterval.None
                };
                    ScheduledActionService.Add(alarm);
    

    For more help, look at this link.