In this post we will see the way to create Alarm and Reminder in Windows Phone.

Creating Alarm

  • Alarm can be created using the Alarm class.
  • Alarm class is part of Microsoft.Phone.Scheduler namespace.
  • Alarm class takes name of the alarm as the input parameter of the constructor.
  • Name of the alarm must be unique within the application.
  • Other properties of Alarm class are as below,

image

You can find explanations of properties are as below. Alarm class is inherited from ScheduleNotification class. Some of the properties are of base class.

image

Alarm can be created as below,


var newAlaram = new Alarm("myalarm")
{
Content="Hey Office Time",
BeginTime= DateTime.Now.AddMinutes(2),
RecurrenceType = RecurrenceInterval.Daily,
ExpirationTime = DateTime.Today.AddDays(30),
// sound= new Uri("music1.wav",UriKind.Relative)
};


ScheduledActionService.Add(newAlaram);


In above code, last line is adding alarm to the phone. ScheduledActionService class add method is used to add alarm to the phone. On running you should be getting alarm after 2 minute of current time as below,

image

Best practice to give name of alarm as a GUID. Since name of the alarm must be unique in the application and it is not visible to the user so it should be given the name as GUID.

Creating Reminder

  • Reminder can be created using Reminder class.
  • Reminder class is part of Microsoft.Phone.Scheduler namespace
  • It is inherited from ScehduleNotification class.
  • Name of the Reminder must be unique in the application
  • Title of the reminder can be set.
  • Custom sound is not supported in reminder. All reminder plays same sound.
  • Reminder can be navigated to a specific page on tapping by the user. This was not supported in Alarm.
  • Other properties are as below,

 

image

Various properties of Reminder is explained below,

image

Reminder can be created as below,


Reminder reminder = new Reminder("myreminder")
{
Title = "Debugmode app reminder",
Content = "Hey Go to party",
BeginTime = DateTime.Now.AddMinutes(2),
RecurrenceType = RecurrenceInterval.Daily,
ExpirationTime = DateTime.Today.AddDays(30),
NavigationUri = new Uri("Page1.xaml", UriKind.Relative)

};

ScheduledActionService.Add(reminder);



In above code, last line is adding reminder to the phone. ScheduledActionService class add method is used to add reminder to the phone. On running you should be getting reminder after 2 minute of current time as below,

image

On tapping user will be navigated to Page1.xaml.

This is how you can create and schedule Alarm and Reminder in Windows Phone. I hope this post is useful. Thanks for reading.

 

Advertisements

7 thoughts on “Creating Alarm and Reminder in Windows Phone

  1. Pingback: WindowsDevNews.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s