diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmKlaxon.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmKlaxon.java index 99cb422..e4a8cb5 100644 --- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmKlaxon.java +++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmKlaxon.java @@ -27,7 +27,6 @@ public class AlarmKlaxon { /** * * TODO allow user to select alarm tone - * TODO prevent alarm from being ignored or snoozing if a call comes in? * */ @@ -37,7 +36,6 @@ public class AlarmKlaxon { telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); initialCallState = telephonyManager.getCallState(); - boolean inTelephoneCall = initialCallState != TelephonyManager.CALL_STATE_IDLE; phoneStateListener = new PhoneStateListener() { @Override public void onCallStateChanged(int state, String ignored) { @@ -46,7 +44,11 @@ public class AlarmKlaxon { // which kills the alarm. Check against the initial call state so // we don't kill the alarm during a call. if (state != TelephonyManager.CALL_STATE_IDLE && state != initialCallState) { - stopAudio(context); + if (mediaPlayer != null) { + mediaPlayer.setVolume(IN_CALL_VOLUME, IN_CALL_VOLUME); + } + // or just stop the audio entirely... + //stopAudio(context); } } }; @@ -68,14 +70,8 @@ public class AlarmKlaxon { }); try { - if (inTelephoneCall) { - Log.d("AlarmKlaxon", "Using the in-call alarm"); - mediaPlayer.setVolume(IN_CALL_VOLUME, IN_CALL_VOLUME); - setDataSourceFromResource(context, mediaPlayer, R.raw.in_call_alarm); - } else { - mediaPlayer.setDataSource(context, alarmNoise); - startAudio(context); - } + mediaPlayer.setDataSource(context, alarmNoise); + startAudio(context); } catch (Exception ex) { // The alarmNoise may be on the sd card which could be busy right // now. Use the fallback ringtone.