Thursday, August 12, 2010

Alarm Clock 1.0

I am starting this post after the completion of my Basic Alarm Clock app. I finally have an alarm clock where the Snooze button is not anywhere close to the disarm/disable button. I have disabled my alarm too many times while trying to snooze, only to wake up hours later, and often late for work.

My answer to this was to learn how to write an Android app and fill a need I had at the same time. I am calling it a 1.0 as it is the first release candidate that has satisfied all my testing requirements. I had a couple false releases, but all within about an hour and quickly went to task fixing the new issue. I finally ended up with a very simple alarm clock.

The main Activity loads and displays an analog clock with the current time, a time picker for selecting an alarm time and an "Enable" check box. This activity only enables and disables any alarms associated with the application.

When an alarm occurs, the snooze Activity is loaded. This display provides 4 different snooze radio buttons (1,2,5,10 Minutes) and a snooze button. A notification is also activated when the alarm occurs. Clicking on it will bring up the snooze Activity display. When the snooze activity is created, the media player is used to play the system alarm sound on loop and the original alarm is cancelled. Clicking the snooze button on the display will cancel the notification, stop the media player, and if the alarm is still enabled, reschedule another alarm to occur according to the snooze time selected. If the alarm was already disabled, the snooze will work only as a disable of the current alarm and doesn't schedule a new alarm.

The only way to disable the occurring alarm is to go back to the main activity display and uncheck the Enable check box. This ensures that I must first snooze the alarm to cancel the notification and sound, then go back to the main display and disable it when I am awake.

I am not attaching my source code because it is not up to my standards of code I would share quite yet. I was short with comments and have a lot of commented debug toast messages that I want to remove. Once I have the code cleaned up a bit and commented better I will be posting it as well. I am sure there will be many places for improvements and I may post a few updates as I clean up/better organize my code.

Screen Shots of the app runing on the Emulator:

2 comments:

  1. Sir can we add multiple alarm to this application, and can u provide me the code for multiple alarm

    ReplyDelete
  2. Unfortunately I will not be updating this app to support multiple alarm times. The specific purpose of this alarm app was to be the absolute most basic possible. The code could probably be a little cleaner but it was never developed for scaling up. It was designed to NOT be scaled.

    ReplyDelete