Example usage for android.provider AlarmClock EXTRA_VIBRATE

List of usage examples for android.provider AlarmClock EXTRA_VIBRATE

Introduction

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

Prototype

String EXTRA_VIBRATE

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

Click Source Link

Document

Bundle extra: Whether or not to activate the device vibrator.

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 w w.  j a  v a  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;
}