Skip to content

Latest commit

 

History

History
52 lines (43 loc) · 1.23 KB

adal-alarm.md

File metadata and controls

52 lines (43 loc) · 1.23 KB

adal-alarm

Android library to add, remove alarms and verify if an alarm exist!

Download

Gradle:

dependencies {
  implementation 'com.massivedisaster.adal:adal-alarm:0.1.20'
}

Usage

/**
 * Add a new alarm to the system.
 */
private void addAlarm() {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());

    if (!AlarmManager.hasAlarm(getContext(), mIntentAlarm, 1001)) {
        AlarmManager.addAlarm(getContext(), mIntentAlarm, 1001, calendar);
        SnackBuilder.show(mBtnRemoveAlarm, "Alarm added!", R.color.colorAccent);
    } else {
        SnackBuilder.show(mBtnAddAlarm, "Alarm already added.", R.color.colorAccent);
    }
}

/**
 * Remove an alarm.
 */
private void removeAlarm() {
    if (AlarmManager.hasAlarm(getContext(), mIntentAlarm, 1001)) {
        AlarmManager.cancelAlarm(getContext(), mIntentAlarm, 1001);
        SnackBuilder.show(mBtnRemoveAlarm, "Alarm removed!", R.color.colorAccent);
    } else {
        SnackBuilder.show(mBtnRemoveAlarm, "Please, add an alarm first!", R.color.colorAccent);
    }
}

Contributing

CONTRIBUTING

License

MIT LICENSE