List of utility methods to do Alarm Start
void | startAlarm(Context context, int type, int index, int hour, int minute, String action) start Alarm Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
if (calendar.getTimeInMillis() < System.currentTimeMillis()) {
calendar.setTimeInMillis(System.currentTimeMillis()
...
|
void | startAlarm(Context context, int type, int index, int interval, String action) start Alarm Intent intent = new Intent(action); intent.putExtra("index", index); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, index, intent, 0); AlarmManager am = (AlarmManager) context .getSystemService(Context.ALARM_SERVICE); am.setRepeating(type, System.currentTimeMillis(), interval, pendingIntent); ... |
MediaPlayer | startAlarmRing(Context c, String tone) Start ringing the alarm using TONE and return the MediaPlayer instance MediaPlayer mPlayer = new MediaPlayer(); Uri toneUri; try { if (tone != null && !tone.equals("")) { toneUri = Uri.parse(tone); } else { toneUri = RingtoneManager .getDefaultUri(RingtoneManager.TYPE_ALARM); ... |
void | start(Context context, Intent broadcastIntent, int requestCode, long delayAtMillis, long period) start PendingIntent sender = genPendingBroadcast(context, requestCode,
broadcastIntent);
long currentTime = SystemClock.elapsedRealtime();
AlarmManager am = (AlarmManager) context
.getSystemService(Context.ALARM_SERVICE);
am.cancel(sender);
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, currentTime
+ delayAtMillis, period, sender);
...
|
void | startImmediately(Context context, Intent broadcastIntent, int requestCode, long period) start Immediately start(context, broadcastIntent, requestCode, 0, period); |