| Talking Reminder this project is intenfed for people who are not tech savvy

BootReceiver.java
1 package com.sudogeeks.talking_reminder;
2
3 import android.content.BroadcastReceiver;
4 import android.content.Context;
5 import android.content.Intent;
6
7 import java.util.Calendar;
8 import java.util.List;
9
15 public class BootReceiver extends BroadcastReceiver {
16
17 // Constant values in milliseconds
18 private static final long milMinute = 60000L;
19 private static final long milHour = 3600000L;
20 private static final long milDay = 86400000L;
21 private static final long milWeek = 604800000L;
22 private static final long milMonth = 2592000000L;
23 private String mTitle;
24 private String mTime;
25 private String mDate;
26 private String mRepeatNo;
27 private String mRepeatType;
28 private String mActive;
29 private String mRepeat;
30 private String[] mDateSplit;
31 private String[] mTimeSplit;
32 private int mYear, mMonth, mHour, mMinute, mDay, mReceivedID;
33 private long mRepeatTime;
34 private Calendar mCalendar;
35 private AlarmReceiver mAlarmReceiver;
36
42 @Override
43 public void onReceive(Context context, Intent intent) {
44 if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
45
46 ReminderDatabase rb = new ReminderDatabase(context);
47 mCalendar = Calendar.getInstance();
48 mAlarmReceiver = new AlarmReceiver();
49
50 List<ReminderDO> reminderDOS = rb.getAllReminders();
51
52 for (ReminderDO rm : reminderDOS) {
53 mReceivedID = rm.getID();
54 mRepeat = rm.getRepeat();
55 mRepeatNo = rm.getRepeatNo();
56 mRepeatType = rm.getRepeatType();
57 mActive = rm.getActive();
58 mDate = rm.getDate();
59 mTime = rm.getTime();
60
61 mDateSplit = mDate.split("/");
62 mTimeSplit = mTime.split(":");
63
64 mDay = Integer.parseInt(mDateSplit[0]);
65 mMonth = Integer.parseInt(mDateSplit[1]);
66 mYear = Integer.parseInt(mDateSplit[2]);
67 mHour = Integer.parseInt(mTimeSplit[0]);
68 mMinute = Integer.parseInt(mTimeSplit[1]);
69
70 mCalendar.set(Calendar.MONTH, --mMonth);
71 mCalendar.set(Calendar.YEAR, mYear);
72 mCalendar.set(Calendar.DAY_OF_MONTH, mDay);
73 mCalendar.set(Calendar.HOUR_OF_DAY, mHour);
74 mCalendar.set(Calendar.MINUTE, mMinute);
75 mCalendar.set(Calendar.SECOND, 0);
76
77 // Cancel existing notification of the reminder by using its ID
78 // mAlarmReceiver.cancelAlarm(context, mReceivedID);
79
80 // Check repeat type
81 if (mRepeatType.equals("Minute")) {
82 mRepeatTime = Integer.parseInt(mRepeatNo) * milMinute;
83 } else if (mRepeatType.equals("Hour")) {
84 mRepeatTime = Integer.parseInt(mRepeatNo) * milHour;
85 } else if (mRepeatType.equals("Day")) {
86 mRepeatTime = Integer.parseInt(mRepeatNo) * milDay;
87 } else if (mRepeatType.equals("Week")) {
88 mRepeatTime = Integer.parseInt(mRepeatNo) * milWeek;
89 } else if (mRepeatType.equals("Month")) {
90 mRepeatTime = Integer.parseInt(mRepeatNo) * milMonth;
91 }
92
93 // Create a new notification
94 if (mActive.equals("true")) {
95 if (mRepeat.equals("true")) {
96 mAlarmReceiver.setRepeatAlarm(context, mCalendar, mReceivedID, mRepeatTime);
97 } else if (mRepeat.equals("false")) {
98 mAlarmReceiver.setAlarm(context, mCalendar, mReceivedID);
99 }
100 }
101 }
102 }
103 }
104 }
com.sudogeeks.talking_reminder.AlarmReceiver.setAlarm
void setAlarm(Context context, Calendar calendar, int ID)
Definition: AlarmReceiver.java:73
com.sudogeeks.talking_reminder.ReminderDatabase.getAllReminders
List< ReminderDO > getAllReminders()
Definition: ReminderDatabase.java:138
com.sudogeeks.talking_reminder.ReminderDO
Data Object class for Reminder This class conatins all the attributes of reminder.
Definition: ReminderDO.java:15
com.sudogeeks.talking_reminder.ReminderDatabase
Class to manage database This class is for managing the database.
Definition: ReminderDatabase.java:15
com.sudogeeks.talking_reminder.BootReceiver
A class For handling the reboot scenarios. In this case this class reschedules the alarms if the devi...
Definition: BootReceiver.java:15
com.sudogeeks.talking_reminder.AlarmReceiver
A class implementing basic alarm functions This class includes very basic features for an alarm.
Definition: AlarmReceiver.java:21
com.sudogeeks.talking_reminder.BootReceiver.onReceive
void onReceive(Context context, Intent intent)
Definition: BootReceiver.java:43
com.sudogeeks.talking_reminder.AlarmReceiver.setRepeatAlarm
void setRepeatAlarm(Context context, Calendar calendar, int ID, long RepeatTime)
Definition: AlarmReceiver.java:107