Example usage for android.provider AlarmClock EXTRA_MESSAGE

List of usage examples for android.provider AlarmClock EXTRA_MESSAGE

Introduction

In this page you can find the example usage for android.provider AlarmClock EXTRA_MESSAGE.

Prototype

String EXTRA_MESSAGE

To view the source code for android.provider AlarmClock EXTRA_MESSAGE.

Click Source Link

Document

Bundle extra: A custom message for the alarm or timer.

Usage

From source file:Main.java

public static void setAlarm(Context context) {
    Intent alarmas = new Intent(AlarmClock.ACTION_SET_ALARM);
    alarmas.putExtra(AlarmClock.EXTRA_MESSAGE, "New Alarm");
    alarmas.putExtra(AlarmClock.EXTRA_HOUR, 10);
    alarmas.putExtra(AlarmClock.EXTRA_MINUTES, 30);
    context.startActivity(alarmas);//w ww . jav a  2s. c o m
}

From source file:com.ephemeraldreams.gallyshuttle.ui.ScheduleActivity.java

/**
 * Build an alarm intent to pass to other activities or alarm applications.
 *
 * @param hour   Alarm hour to set.//from   ww w . j  a  va 2s  . c om
 * @param minute Alarm minute to set
 * @return Alarm intent.
 */
private Intent buildAlarmIntent(int hour, int minute) {
    Intent alarmIntent = new Intent(AlarmClock.ACTION_SET_ALARM);
    CharSequence station = scheduleViewPager.getAdapter().getPageTitle(scheduleViewPager.getCurrentItem());
    alarmIntent.putExtra(AlarmClock.EXTRA_MESSAGE, station + " arrival reminder.");
    alarmIntent.putExtra(AlarmClock.EXTRA_SKIP_UI, false);
    alarmIntent.putExtra(AlarmClock.EXTRA_HOUR, hour);
    alarmIntent.putExtra(AlarmClock.EXTRA_MINUTES, minute);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        alarmIntent.putExtra(AlarmClock.EXTRA_VIBRATE, alarmVibrationBooleanPreference.get());
        if (TextUtils.isEmpty(alarmRingtoneChoiceStringPreference.get())) {
            alarmIntent.putExtra(AlarmClock.VALUE_RINGTONE_SILENT, true);
        } else {
            alarmIntent.putExtra(AlarmClock.EXTRA_RINGTONE, alarmRingtoneChoiceStringPreference.get());
        }
    }
    return alarmIntent;
}

From source file:com.forrestguice.suntimeswidget.AlarmDialog.java

public static void scheduleAlarm(Activity context, String label, Calendar calendar) {
    if (calendar == null)
        return;//from  w  w  w  .j a v a  2  s  .c o  m

    Calendar alarm = new GregorianCalendar(TimeZone.getDefault());
    alarm.setTimeInMillis(calendar.getTimeInMillis());
    int hour = alarm.get(Calendar.HOUR_OF_DAY);
    int minutes = alarm.get(Calendar.MINUTE);

    Intent alarmIntent = new Intent(AlarmClock.ACTION_SET_ALARM);
    alarmIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    alarmIntent.putExtra(AlarmClock.EXTRA_MESSAGE, label);
    alarmIntent.putExtra(AlarmClock.EXTRA_HOUR, hour);
    alarmIntent.putExtra(AlarmClock.EXTRA_MINUTES, minutes);

    if (alarmIntent.resolveActivity(context.getPackageManager()) != null) {
        context.startActivity(alarmIntent);
    }
}