Monday, May 6, 2013

Setting Alarm in Windows Phone

Today, we would see how we can set notifications in Windows phone application. There are two type of notifications that can be set in Windows phone

  • Alarm
  • Reminder
We would see how we can set ALARM in windows phone application.

1) Create a Windows phone application
2) Add following namespace
using Microsoft.Phone.Scheduler;

3) Following are the properties of Alarm class

a) Content - Specify the text you want to show when Alarm is triggered
b) Sound - You can specify any sound file to be played when Alarm is triggered
c) BeginTime - Specify the time when you want Alarm to be triggered
d) Expiration Time - Specify the time / days / month / year you want Alarm to be triggered

4) Below is the code for setting the Alarm in Windows Phone

            var NewAlarm = new Alarm("MyNewAlarm");

            NewAlarm.Content = "Testing Alarm";
            NewAlarm.Sound = new Uri("MaulaMere.mp3", UriKind.Relative);
            NewAlarm.BeginTime = DateTime.Now.AddMinutes(1);
            NewAlarm.ExpirationTime = DateTime.Now.AddDays(30);

            ScheduledActionService.Add(NewAlarm);

Hope this article of mine provide the basic knowledge of Alarm in Windows Phone

No comments:

Post a Comment