Example usage for android.provider AlarmClock VALUE_RINGTONE_SILENT

List of usage examples for android.provider AlarmClock VALUE_RINGTONE_SILENT

Introduction

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

Prototype

String VALUE_RINGTONE_SILENT

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

Click Source Link

Document

Bundle extra value: Indicates no ringtone should be played.

Usage

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  w ww.ja  va 2 s  .co  m
 * @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;
}