Free Online Courses for Software Developers - MrBool
× Please, log in to give us a feedback. Click here to login

You must be logged to download. Click here to login


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

Android KitKat: How to Create A Time Based Reminder Application

In this article we will see how to create a time based reminder application in Android using Android version 4.4 KITKAT. Such application will remind the user for any work or activity at a particular time.

A large number of Smart Phone applications are being designed increasingly each and every day which provides significant services in easiest way to the users in their daily life.

In this article I will show you how to create a time based reminder application in Android using Android version 4.4 KITKAT. Such application will remind the user for any work or activity at a particular time. First of all, I will give an intro of Android version 4.4 KITKAT and the new features and APIs that are present in Android 4.4 which are not present in previous versions of Android.

Android 4.4 KITKAT

Android 4.4 (KITKAT) is a latest release of the Android platform which provides new and amazing features for different Android users and Android application developers. For developing Android applications using Android version 4.4 KITKAT, the developer should have Android 4.4 Software Development Kit (SDK) platform. If not, then it should be downloaded to make your Android Application IDE (e.g. Eclipse) and SDK updated to KITKAT.

To test applications based on Android version 4.4, the developer should have a device having Android version 4.4. But if the developer wants to run the application without having Android version 4.4 device, then the alternate is to run the application on Android Emulator. For running applications on Android Emulator for Android 4.4, the developer should set the targetSdkVersion to "19" (API level of KITKAT). For using APIs of Android 4.4 and also having support of previous and older versions of Android, the developer should add certain conditions to his/her code which check the API level of the system before running those APIs which are not being supported by the minSdkVersion of the Android Emulator.

What’s New in Android 4.4 KITKAT

The Android 4.4 KITKAT contains new APIs and new Features for developers as well as users. Following are few of these:

External Storage

There are two types of External Storage permissions that were initiated in Android 4.1; READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE. READ_EXTERNAL_STORAGE permission was presented to complement WRITE_EXTERNAL_STORAGE but in Android 4.1, it wasn’t required. Therefore, this permission is now imposed in Android 4.4, but in a different way. External storage, has been divided into two main parts; the app-specific directories for the application and everything else.

In Android 4.4, no permissions are required for reading or writing of data in any application’s specific location. The External Storage permissions are applied to any directory which is obtained from functions of Context like getExternalFilesDir() or getExternalCacheDir() (see Links section). If the developer is using these directories, then he/she will be able to remove WRITE_EXTERNAL_STORAGE permission in his/her application. For reading of data that exists anywhere on external storage, then the applications must contain either READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE permission.

Hiding Contents

In Android 4.0, the applications had the capability of hiding the contents like status bar and navigation buttons temporarily by using the View.SYSTEM_UI_FLAG_FULLSCREEN and View.SYSTEM_UI_FLAG_HIDE_NAVIGATION flags where the visual displaying contents might cover the whole display. But such mode was not interactive for the user, and the User Interface (UI) controls were soon displayed as soon as the user had tapped anywhere on the screen. In Android 4.4, new layout flags are introduced for the purpose of toggling the visibility of System UI. The View.SYSTEM_UI_FLAG_IMMERSIVE and View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY have been added to expand this. These new flags, when used in concert with the flags stated before, then the same System UI could be hidden while the user is having interaction with the content of full screen application.

Application Shortcuts

In Android 4.4, two new permissions are introduced to make the permissions public for applications to directly remove or add shortcuts icons of applications. These permissions are INSTALL_SHORTCUT and UNINSTALL_SHORTCUT. Previously these permissions were defined inside the Application Launcher rather than SDK which is public in Android 4.4.

New Array Types

In Android 4.4, new memory-efficient arrays were introduced in ArrayMap platform. In previous versions of Android, SparseArray, SparseIntArray etc. were present which were used to improve the execution performance by decreasing the allocation of data in case of using different types of primitives such as keys. But the ArrayMap permits mapping of full key-value with objects, but the disadvantage is that it is somehow more aggressive than the java.util.HashMap class in sizing the capacity, which keeps the object allocations to decrease when the capacity and item count are increased. In addition to this, the ArrayMap also make the memory low by reducing memory size when the items are removed.

Changes in WebView

In Android 4.4, the code in the WebView class had upgraded in such a way that it is based on the Google Chromium source code which provides a wide range of improvements to the device performance. It provides support for remote debugging of WebView content [2]. Furthermore, it also provides support for the new features of HTML5 and CSS3. If your application is using WebView, then the performance of the application may be decreased sometime. The evaluateJavascript() method of WebView class provides a new way of running JavaScript which helps in supporting callback result.

These are some of the major changes that are done to launch Android 4.4. A large number of changes and updates are being , but these items are outside the scope of this article.

Creating Time Based Reminder Application in Android v 4.4

The purpose of time based reminder application is to set reminder on the basis of time like alarming someone on the particular time which the user had set for any work. When the time of the device and the time the user had set matches, then reminder will be invoked and will alarm the user for that work. The reminder is set in such a way that the user gets the current time of the system and the desired alarm time from the Google Calendar API, which then using the AlarmManager class, then invoke the alarm when the two times matches.

Main Activity or Reminders Activity

After creating a new project, the first and foremost activity (or Main Activity) is based on displaying the list of reminders that the user had set for some work. The Activity name should be extended from ListActivity class to make itself allow for using different methods of ListActivity which will be useful in creating Lists. Then for storing such reminders in the database, the database file should be created which helps in providing different features of databases. I have made the database file in the ReminderDB Activity, which I will discuss shortly.

Listing 1. RemeinderList Activity

public class ReminderList extends ListActivity {
	private ReminderListAdapter mAdapter;
	private ReminderDBSupporter dbHelper = new ReminderDBSupporter(this);
	protected void onCreate(Bundle savedInstanceState) {
		mContext = this;
		mAdapter = new ReminderListAdapter(this, dbHelper.getReminders());
	public void setReminderEnabled(long id, boolean isEnabled) {
		ReminderModel model = dbHelper.getReminder(id);
		model.isEnabled = isEnabled;
	public void startReminderDetailsActivity(long id) {
		Intent intent = new Intent(this, ReminderDetails.class);
		intent.putExtra("id", id);
		startActivityForResult(intent, 0);	
public void deleteReminder(long id) {
		final long reminderId = id;
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setMessage("Please confirm")
		.setTitle("Delete set?")
		.setNegativeButton("Cancel", null)
		.setPositiveButton("Ok", new OnClickListener() {
	public void onClick(DialogInterface dialog, int which) {
dbHelper.deleteReminder(reminderId);						                      mAdapter.setReminders(dbHelper.getReminders());
		}).show();	}		}

As stated above, the ReminderList class contains different methods for performing different operations on newly created Reminders. First, the setReminderEnabled() method checks whether the created reminder or reminders are enabled or not. Then the startReminderDetailsActivity() method provides the details and description about different created reminders. Finally, the deleteReminder() method is used to delete the unused or unwanted reminder that is created by the user. It contains the confirmation message box which asks about the confirmation of reminder that whether the user really wants to delete the reminder. If not, then there will be a cancel option by which the user can cancel the performed operation. The XML activity file for the above activity contains ListView which displays list of all the reminder items that are saved by the user for the purpose of setting up different reminders. The ListView will display all the saved reminders in first-come first serve fashion, in which the reminder that is set and saved first will be displayed at the top of the list.

Reminder Details Activity

This activity performs different operations on previously created reminders and also makes way to create new reminders, and then perform different operations on the newly created reminders. The CustomSwitch class is used which is one of the new features of Android. The CustomSwitch class allows users to enable or disable the reminders by tapping on the CustomSwich option. It can also be used for repeating processes which allow users to repeat reminders weekly or on any particular day by providing different logic through programming. When the reminder is set then there comes the turn for setting up a ringtone. For this, RingtoneManager class is used which gets the ringtone from the ringtones of the device to be set and the user can set any ringtone present in the device. After the reminder is created, the user can then update the reminders by changing different values and also can change the ringtone.

Listing 2. ReminderDetails class

public class ReminderDetails extends Activity {
	private ReminderModel reminderDetails;
	private TimePicker timePicker;
	private EditText edtName;
	private ReminderCustomSwitch chkWeekly;
	private ReminderCustomSwitch chkSunday;
	private TextView txtToneSelection;
protected void onCreate(Bundle savedInstanceState) {
	timePicker = (TimePicker) findViewById(;
	edtName = (EditText) findViewById(;
	chkWeekly = (ReminderCustomSwitch) findViewById(;
	chkSunday = (ReminderCustomSwitch) findViewById(;
	txtToneSelection = (TextView) findViewById(;
txtToneSelection.setText(RingtoneManager.getRingtone(this, reminderDetails.reminderTone).getTitle(this));
final LinearLayout ringToneContainer = (LinearLayout)				findViewById(;
	ringToneContainer.setOnClickListener(new OnClickListener() {
	public void onClick(View v) {
	Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
			startActivityForResult(intent , 1);
			}		});	}
private void updateModelFromLayout() {		
	reminderDetails.timeMinute = timePicker.getCurrentMinute().intValue();
	reminderDetails.timeHour = timePicker.getCurrentHour().intValue(); = edtName.getText().toString();
	reminderDetails.repeatWeekly = chkWeekly.isChecked();	
reminderDetails.setRepeatingDay(ReminderModel.SUNDAY, chkSunday.isChecked());	
		reminderDetails.isEnabled = true;

As stated above, the RemainderDetail class is inherited from the Activity class which can use all the public operations of the Activity class anywhere in the activity. Then to get access to the database, the object of the ReminderDBSupporter class is initialized inside the activity, which provides all the necessary operations required for dealing with the database. Then, for getting details about different contents of the reminders, the object of ReminderModel class is initialized which will provide all the required contents related to the details of reminders.

Furthermore, for repetition of reminders on different basis, the CustomSwitch is used which can be obtained by introducing objects of ReminderCustomSwitch class which will initialize objects for all the seven days of the week and if anyone wants to repeat the reminder on weekly basis, then he/she may check the repeat weekly CustomSwitch option. At the end of the activity, there is a TextView for choosing and selecting a ringtone for the particular saved reminder. It uses the RingtoneManager class for picking any ringtone for the saved reminder. Finally, to update any saved reminder, the updateModelFromLayout() method will do all that is necessary for updating and makinge changes in any saved reminder.

Reminder List Adapter Activity

For displaying an array of custom list items in a ListView, the ArrayAdapter class is used but its disadvantage is that it does not display more contents. For this reason, the class should be extended from BaseAdapter. Extending the class from BaseAdapter allows to display even more contents and more elements in a list.

Listing 3. ReminderListAdapter class

public class ReminderListAdapter extends BaseAdapter {
	private Context mContext;
	private List<ReminderModel> mReminders;
	public void setReminders(List<ReminderModel> reminders) {
		mReminders = reminders;
	public long getItemId(int position) {
		if (mReminders != null) {
			return mReminders.get(position).id;		}
		return 0;	}
	public View getView(int position, View view, ViewGroup parent) {
		if (view == null) {
	LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.reminder_item_list, parent, false);		}
ReminderModel model = (ReminderModel) getItem(position);
TextView txtTime = (TextView) view.findViewById(;
txtTime.setText(String.format("%02d : %02d", model.timeHour, model.timeMinute));
TextView txtName = (TextView) view.findViewById(;
ToggleButton btnToggle = (ToggleButton) view.findViewById(;
	btnToggle.setChecked(model.isEnabled);			}

In the above activity, the ReminderListAdapter class is extended from the BaseAdapter class which will display more elements and contents in a list of saved reminders. The ReminderModel class is used as a list reference in the List class which then initializes an object of it which is used for applying different operations on reminders. The getView() method will then display reminders data at the definite position in the List of reminders. The View is then inflated from the layout XML file.

Reminder Model Activity

In this activity, different instances are initialized for different elements which are then used for operations in the other classes of the project.

Listing 4. ReminderModel class

public class ReminderModel {
	public static final int SUNDAY = 0;
	// initialize for all the days of the week
public long id = -1;
	public int timeHour;
	public int timeMinute;
	private boolean repeatingDays[];
	public boolean repeatWeekly;
	public Uri reminderTone;
	public String name;
	public boolean isEnabled;
public ReminderModel() {
		repeatingDays = new boolean[7];	}
public void setRepeatingDay(int dayOfWeek, boolean value) {
		repeatingDays[dayOfWeek] = value;		}
	public boolean getRepeatingDay(int dayOfWeek) {
		return repeatingDays[dayOfWeek];		}	}

Reminder Invocation Screen Activity

This activity displays different information of the reminder when the reminder is invoked, such as reminder text. In addition to this, the screen also displays the time of the invoked reminder. The name or working text of the reminder is also shown. Finally, there is a button to dismiss the reminder when the reminder is successfully invoked.

Listing 5. ReminderScreen class

public class ReminderScreen extends Activity {
	private WakeLock mWakeLock;
	private MediaPlayer mPlayer;
	protected void onCreate(Bundle savedInstanceState) {
		String name = getIntent().getStringExtra(ReminderHelper.NAME);
		int timeHour = getIntent().getIntExtra(ReminderHelper.TIME_HOUR, 0);
		int timeMinute = getIntent().getIntExtra(ReminderHelper.TIME_MINUTE, 0);
		String tone = getIntent().getStringExtra(ReminderHelper.TONE);

		TextView tvName = (TextView) findViewById(;
		TextView tvTime = (TextView) findViewById(;
		tvTime.setText(String.format("%02d : %02d", timeHour, timeMinute));
		Button endReminder = (Button) findViewById(;
		endReminder.setOnClickListener(new OnClickListener() {
			public void onClick(View view) {
				finish();	}	});
		mPlayer = new MediaPlayer();
		try {
			if (tone != null && !tone.equals("")) {
				Uri toneUri = Uri.parse(tone);
				if (toneUri != null) {
					mPlayer.setDataSource(this, toneUri);
		} catch (Exception e) {
		PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE);
		if (mWakeLock == null) {
			mWakeLock = pm.newWakeLock((PowerManager.FULL_WAKE_LOCK | PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), TAG);
		}	}

As stated above, the object of WakeLock class is instantiated, which makes your device in ON state during processing of your application. It deals with the power management of the device. It is used to keep the CPU of the device in the running state and also to avoid the application screen from turning off and dimming. After this, for playing reminder tone, the object of the MediaPlayer class is initialized. Then for displaying the rest views, the different methods and operations, as stated above, should be applied to get the desired functions. The parse() method of the Uri class, in the above activity is used to parse the ringtone parameter given as an argument in the method. Such ringtone is used as a reminder ringtone which is played when the reminder is invoked. The PowerManager class provides control of the state of power of your device. The battery life of the device will be much more improved using this API.

Reminder Helper Activity class

The necessary requirements for helping out the reminders to successfully invoke and also setting the reminders are provided by this activity. The class is extended from BroadcastReceiver API which will enable the user to register for the application or system events. This activity provides the system requirements that are necessary for the application during event execution. Let’s look at the activity’s code.

Listing 6. ReminderHelper class

public class ReminderHelper extends BroadcastReceiver {

	public static final String ID = "id";
	public static final String NAME = "name";
	public static final String TIME_HOUR = "timeHour";
	public static final String TIME_MINUTE = "timeMinute";
	public static final String TONE = "reminderTone";
	public static void setReminders(Context context) {
	ReminderDBSupporter dbHelper = new ReminderDBSupporter(context);
	List<ReminderModel> reminders = dbHelper.getReminders();
	for (ReminderModel reminder : reminders) {
			if (reminder.isEnabled) {
	Calendar calendar = Calendar.getInstance();
	calendar.set(Calendar.HOUR_OF_DAY, reminder.timeHour);
	calendar.set(Calendar.MINUTE, reminder.timeMinute);
		calendar.set(Calendar.SECOND, 00);
final int nowDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final int nowHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
final int nowMinute = Calendar.getInstance().get(Calendar.MINUTE);
			boolean reminderSet = false;
private static void setReminder(Context context, Calendar calendar, PendingIntent pIntent) {
AlarmManager alarmManager =     (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
alarmManager.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pIntent);

As you can see above, the different strings initialized are used during the setting of the reminder which are used in this class as well as in other class of the application discussed before. The setReminders() method apply different operations on the reminders that are set previously. The ReminderDBSupporter class provides the contents of the database that are required during setting the reminder. Again the ReminderModel class is used as a list reference in the List, which in this class, is again used for applying different operations on reminders. The Calendar class is used to provide linking and matching of saved reminders timing and system timing. When the two times match, then the reminder will be invoked. The PedengIntent class enables you to execute the AlarmManager contents which provides access to the services of the alarm. The AlarmManager.RTC_WAKEUP is used to trigger the alarm according to the time of the clock.

Reminder Database Support class

This activity contains the contents of the database and provides support to those classes of the application that needs access to the database contents. The class is extended from SQLiteOpenHelper which is used to manage creation of the database and version management.

Listing 7. ReminderDBSupporter class

public class ReminderDBSupporter extends SQLiteOpenHelper {
    public static final String DATABASE_NAME = "reminder.db";
private static final String SQL_CREATE_REMINDER = "CREATE TABLE " + Reminder.TABLE_NAME + " (" + Reminder._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
	    " )";	
private static final String SQL_DELETE_REMINDER ="DROP TABLE IF EXISTS " +   Reminder.TABLE_NAME;
	public void onCreate(SQLiteDatabase db) {
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        		onCreate(db);		}
public long createReminder(ReminderModel model) {
		ContentValues values = populateContent(model);
        return getWritableDatabase().insert(Reminder.TABLE_NAME, null, values);	}
public long updateReminder(ReminderModel model) {
		ContentValues values = populateContent(model);
        return getWritableDatabase().update(Reminder.TABLE_NAME, values, Reminder._ID + " =                                                ?", new String[] { String.valueOf( });	}
public ReminderModel getReminder(long id) {
		SQLiteDatabase db = this.getReadableDatabase();
String select = "SELECT * FROM " + Reminder.TABLE_NAME + " WHERE " + Reminder._ID  + " = " + id;
		Cursor c = db.rawQuery(select, null);
		if (c.moveToNext()) {
			return populateModel(c);		}
		return null;	}
public List<ReminderModel> getReminders() {
		SQLiteDatabase db = this.getReadableDatabase();
       String select = "SELECT * FROM " + Reminder.TABLE_NAME;
	Cursor c = db.rawQuery(select, null);
List<ReminderModel> reminderList = new ArrayList<ReminderModel>();
		while (c.moveToNext()) {
		reminderList.add(populateModel(c));	}
	if (!reminderList.isEmpty()) {
			return reminderList;		}
			return null;	}
public int deleteReminder(long id) {
		return getWritableDatabase().delete(Reminder.TABLE_NAME, Reminder._ID + " = ?", new String[] { String.valueOf(id) });
	}	}

As stated above, the class contain different strings for the creation of the table and table columns, which are simply assigned to a single string SQL_CREATE_REMINDER. Then the class contains strings and methods to define the basic SQL operations. The Cursor class provides read and write access to the result set which is returned by a database query.


Time Based Reminders are of great need in today’s world, which help make you a punctual person. It is necessary to set reminder or reminders which will remind you about the particular work. In this article, I have showed you how to create multiple reminders for a single or multiple tasks which will enable you to perform your work and tasks effectively and efficiently without losing your concentration about any sort of work.


I am Computer Science Graduate having hands-on experience in Android, PHP, MySQL, CSS, Javascript, HTML etc.

What did you think of this post?
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!

> More info about MrBool Credits
You must be logged to download.

Click here to login