Android Utililty Methods Alarm Start

List of utility methods to do Alarm Start

Description

The list of methods to do Alarm Start are organized into topic(s).

Method

voidstartAlarm(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()
...
voidstartAlarm(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);
...
MediaPlayerstartAlarmRing(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);
...
voidstart(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);
...
voidstartImmediately(Context context, Intent broadcastIntent, int requestCode, long period)
start Immediately
start(context, broadcastIntent, requestCode, 0, period);