Search in sources :

Example 1 with AlarmHandler

use of com.health.openscale.core.alarm.AlarmHandler in project openScale by oliexdev.

the class ReminderPreferences method updateAlarmPreferences.

private void updateAlarmPreferences() {
    ComponentName receiver = new ComponentName(getActivity().getApplicationContext(), ReminderBootReceiver.class);
    PackageManager pm = getActivity().getApplicationContext().getPackageManager();
    AlarmHandler alarmHandler = new AlarmHandler();
    if (reminderEnable.isChecked()) {
        alarmHandler.scheduleAlarms(getActivity());
        pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
    } else {
        alarmHandler.disableAllAlarms(getActivity());
        pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    }
}
Also used : PackageManager(android.content.pm.PackageManager) ComponentName(android.content.ComponentName) AlarmHandler(com.health.openscale.core.alarm.AlarmHandler)

Aggregations

ComponentName (android.content.ComponentName)1 PackageManager (android.content.pm.PackageManager)1 AlarmHandler (com.health.openscale.core.alarm.AlarmHandler)1