@Override public void onReceive(Context context, Intent intent) { LogHandler.configureLogger(); try { String log = "onReceive: Action: "; log += intent.getAction(); log += "( "; if (intent.getData() != null) { log += intent.getData().getScheme(); log += "://"; log += intent.getData().getHost(); } log += " ) "; Bundle extras = intent.getExtras(); log += "{ "; if (extras != null) { for (String extra : extras.keySet()) { log += extra + "[" + extras.get(extra) + "], "; } } log += " }"; Log.d(this, log); } catch (Exception e) { Log.e(e); } try { if (ExternalAppConstants.SLEEP_AS_ANDROID_ALARM_EVENT .ALARM_TRIGGERED .getIntentAction() .equals(intent.getAction())) { Log.d("IntentReceiver", "Alarm triggered!"); ActionHandler.execute( context, ExternalAppConstants.SLEEP_AS_ANDROID_ALARM_EVENT.ALARM_TRIGGERED); } else if (ExternalAppConstants.SLEEP_AS_ANDROID_ALARM_EVENT .ALARM_SNOOZED .getIntentAction() .equals(intent.getAction())) { Log.d("IntentReceiver", "Alarm snoozed..."); ActionHandler.execute( context, ExternalAppConstants.SLEEP_AS_ANDROID_ALARM_EVENT.ALARM_SNOOZED); } else if (ExternalAppConstants.SLEEP_AS_ANDROID_ALARM_EVENT .ALARM_DISMISSED .getIntentAction() .equals(intent.getAction())) { Log.d("IntentReceiver", "Alarm dismissed..."); ActionHandler.execute( context, ExternalAppConstants.SLEEP_AS_ANDROID_ALARM_EVENT.ALARM_DISMISSED); } else { Log.d("IntentReceiver", "Received unknown intent: " + intent.getAction()); } } catch (Exception e) { Log.e(e); } }
@Override public void onReceive(Context context, Intent intent) { LogHandler.configureLogger(); Log.d(this, intent); try { if (intent.getAction().equals(TimerConstants.TIMER_ACTIVATION_INTENT)) { Log.d(this, "parsing timer activation intent..."); parseActionIntent(context, intent); } else if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) { // restart all active alarms because device rebooted Log.d(this, "restarting all active alarms because device rebooted..."); reinitializeAlarms(context); } else { Log.d(this, "Received unknown intent: " + intent.getAction()); } } catch (Exception e) { Log.e(e); } }