@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: { finish(); break; } case R.id.action_save_alarm_details: { updateModelFromLayout(); AlarmManagerHelper.cancelAlarms(this); if (alarmDetails.id < 0) { dbHelper.createAlarm(alarmDetails); } else { dbHelper.updateAlarm(alarmDetails); } AlarmManagerHelper.setAlarms(this); setResult(RESULT_OK); finish(); } } return super.onOptionsItemSelected(item); }
public void setAlarmEnabled(long id, boolean isEnabled) { AlarmManagerHelper.cancelAlarms(this); AlarmModel model = dbHelper.getAlarm(id); model.isEnabled = isEnabled; dbHelper.updateAlarm(model); AlarmManagerHelper.setAlarms(this); }
@Override public int onStartCommand(Intent intent, int flags, int startId) { Intent alarmIntent = new Intent(getBaseContext(), AlarmScreen.class); alarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); alarmIntent.putExtras(intent); getApplication().startActivity(alarmIntent); AlarmManagerHelper.setAlarms(this); return super.onStartCommand(intent, flags, startId); }