Browse through more Android tutorials. If you'd like to see a tutorial on any particular topic, do leave a comment in the wishlist page. We frequently post new tutorials along with app releases. You may subscribe to our newsletter to get all updates in your inbox.
Now you can get the latest Java source bundled with each app update. Install the app from Google Play and go to Settings > Extras.

«  Create an instant messaging app Create a SMS app  »

Create an elegantly designed Reminder/Alarm clock application

DownloadDownload
By

Keywords: ListActivity SimpleCursorAdapter SQLiteDatabase AlarmManager NotificationManager IntentService BroadcastReceiver ToggleButton ViewSwitcher DatePicker TimePicker RadioGroup

Contents
  • RemindMe
    • assets
      • fonts
        • Font.ttf
    • src
      • com
        • appsrox
          • remindme
            • ui
              • CheckedImageView.java
              • TagAdapter.java
              • OnSwipeTouchListener.java
              • NavAdapter.java
            • model
              • AlarmTime.java
              • AlarmMsg.java
              • Alarm.java
              • AbstractModel.java
              • DbHelper.java
            • UserActivity.java
            • AlarmSetter.java
            • ShowcaseActivity.java
            • AddAlarmActivity.java
            • Util.java
            • AlarmService.java
            • ChartView.java
            • MainActivity.java
            • ManageActivity.java
            • AlarmReceiver.java
            • RemindMe.java
            • SettingsActivity.java
    • res
      • drawable-xhdpi
        • apptheme_textfield_activated_holo_light.9.png
        • apptheme_textfield_disabled_focused_holo_light.9.png
        • apptheme_textfield_default_holo_light.9.png
        • drawer_shadow.9.png
        • tag.png
        • ringtone.png
        • insistent.png
        • sound.png
        • ic_launcher.png
        • apptheme_textfield_disabled_holo_light.9.png
        • apptheme_textfield_focused_holo_light.9.png
        • vibrate.png
      • xml
        • pref_general.xml
        • pref_headers.xml
        • pref_notification.xml
      • drawable-mdpi
        • noisy_grid1.png
        • ok.png
        • preferences.png
        • dismiss.png
        • drawer_shadow.9.png
        • noisy_grid.png
        • list_lines.png
        • ic_dialog_menu_generic.png
        • m_edit.png
        • m_delete.png
        • edit.png
        • m_add.png
        • add.png
        • title_bar_shadow.9.png
      • values-sw600dp
        • dimens.xml
      • menu
        • manage.xml
        • context_menu.xml
        • options_menu.xml
      • drawable-xxhdpi
        • calendar.png
        • apptheme_btn_radio_off_focused_holo_light.png
        • clock.png
        • apptheme_btn_radio_off_disabled_focused_holo_light.png
        • clock0.png
        • apptheme_btn_radio_on_focused_holo_light.png
        • bell.png
        • apptheme_btn_radio_off_pressed_holo_light.png
        • apptheme_btn_radio_on_holo_light.png
        • apptheme_btn_radio_on_disabled_holo_light.png
        • apptheme_btn_radio_off_disabled_holo_light.png
        • hourglass.png
        • apptheme_btn_radio_off_holo_light.png
        • apptheme_btn_radio_on_disabled_focused_holo_light.png
        • apptheme_btn_radio_on_pressed_holo_light.png
      • layout
        • activity_add.xml
        • activity_manage.xml
        • include_onetime.xml
        • include_repeating.xml
        • edit.xml
        • content.xml
        • row_manage.xml
        • activity_main.xml
        • drawer_list_item.xml
        • row_main.xml
        • activity_showcase.xml
        • activity_user.xml
      • values-sw720dp-land
        • dimens.xml
      • drawable-hdpi
        • nav_call.png
        • nav_birthday.png
        • nav_alarm.png
        • nav_pill.png
        • drawer_shadow.9.png
        • right.png
        • nav_gym.png
        • nav_meeting.png
        • nav_todo.png
        • more.png
        • nav_bills.png
        • nav_appointment.png
        • nav_all.png
        • left.png
        • nav_event.png
        • nav_groceries.png
      • drawable
        • header.xml
        • range.xml
        • bg_repeat1.xml
        • apptheme_edit_text_holo_light.xml
        • nav_item_selector.xml
        • line.xml
        • btn_selector.xml
        • apptheme_btn_radio_holo_light.xml
        • empty.xml
        • bg_repeat.xml
        • shade.xml
        • btn2_selector.xml
        • rect.xml
        • button_blue.xml
        • circle.xml
        • onetime.xml
        • repeating.xml
        • type_selector.xml
        • square.xml
        • transparent.xml
      • values
        • arrays.xml
        • dimens.xml
        • strings_activity_settings.xml
        • strings.xml
        • styles.xml
        • colors.xml
    • AndroidManifest.xml

1. Overview

In this article, we show you how to create a alarm/notifications application in Android. Everyone needs a app like this since we have to remember a lot of things in life. Moreover, it serves as a record of events which you might want to revisit later.
The app essentially uses the Alarm system service provided by Android to set alarms and Notification system service for notifications. There are a few things apart from this which we'll discuss in the tutorial. The other highlight of the app is its simple yet elegant user interface which you will learn to design.
Here is the design of the app.

Screenshot Screenshot

The main screen is implemented using ListView with a custom layout for the rows. And the new reminder screen uses a ViewSwitcher and few other Android widgets.
There is also a settings screen which we will cover in the tutorial, so let's start coding!

2. Create a new Eclipse Android project

In Eclipse, go to File > New > Project and in the New Project dialog, expand Android folder to select Android Project.
In New Android Project dialog enter the project details as follows.
Project name: RemindMe
Build Target: Android 2.1
Application name: Remind Me
Package name: com.appsrox.remindme
Create Activity: MainActivity
Click Finish. The project gets created in your workspace.

3. Define the Data model

The data model of the application essentially comprises of tables to hold user provided data and runtime data. The Alarm table holds the notification message and other user provided data whereas AlarmTime table holds just the time of the alarm. This design allows us to add/delete multiple alarm timings. The Notification table holds runtime data such as alarm status etc. Class Diagram Create a package com.appsrox.smartpad.model to hold the data model classes. Additionally, create DbHelper class which extends SQLiteOpenHelper.
Android provides SQLite database for data persistence and SQLiteOpenHelper class for managing the database. We have covered these topics along with code snippets in an earlier article which you may want to refer.

4. The Android Manifest file

The AndroidManifest.xml describes the Android application. We need to edit this file to declare various components, features, permissions, etc. used by the application.
Here you can see the entire content of the file but it is modified incrementally as we develop various components.
	<?xml version="1.0" encoding="utf-8"?>
	<manifest xmlns:android="http://schemas.android.com/apk/res/android"
		package="com.appsrox.remindme"
		android:versionCode="1"
		android:versionName="1.0" >

		<uses-sdk android:minSdkVersion="7" />
		
		<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
		<uses-permission android:name="android.permission.VIBRATE" />

		<application
			android:name=".RemindMe"
			android:icon="@drawable/ic_launcher"
			android:label="@string/app_name"
			android:theme="@style/app_theme" >
			
			<activity
				android:name=".MainActivity"
				android:label="@string/app_name" >
				<intent-filter>
					<action android:name="android.intent.action.MAIN" />
					<category android:name="android.intent.category.LAUNCHER" />
				</intent-filter>
			</activity>
			<activity 
				android:name=".AddAlarmActivity" 
				android:windowSoftInputMode="stateHidden"></activity>
			<activity android:name=".SettingsActivity"></activity>
			
			<receiver android:name=".AlarmSetter">
				<intent-filter>
					<action android:name="android.intent.action.BOOT_COMPLETED" />
				</intent-filter>
			</receiver>
			<receiver android:name=".AlarmReceiver"></receiver>
			
			<service android:name=".AlarmService"></service>
		</application>

	</manifest>
						
As you can see we have declared two receivers and a service along with activities to make the application work. We will discuss about these components in detail later.

5. The Application class

The Application class is a good place to declare all globals in an application although it's not mandatory. To use it we create a class which extends Application and override onCreate() method where the variables are instantiated.
	public class RemindMe extends Application {
		
		public static DbHelper dbHelper;
		public static SQLiteDatabase db;
		public static SharedPreferences sp;

		@Override
		public void onCreate() {
			super.onCreate();
			
			PreferenceManager.setDefaultValues(this, R.xml.settings, false);
			sp = PreferenceManager.getDefaultSharedPreferences(this);
			
			dbHelper = new DbHelper(this);
			db = dbHelper.getWritableDatabase();		
		}
		
		public static String getRingtone() {
			return sp.getString(RemindMe.RINGTONE_PREF, DEFAULT_NOTIFICATION_URI.toString());
		}		

	}
					
Notice that in AndroidManifest.xml we have declared the Application class using the <application> tag.
In the next section we'll develop the Preference screen which enables a user to customize various aspects of the application.
Share the love:  

Next Page » 1

App Gen
App Name:
Project Name:
Package:
Screens:
Splash
Login
Help
Main
List  Grid  Pager
Detail
Settings
Options:
Action Bar
Navigation Drawer
Dummy Data
Generate
Free Apps