Additional notification cancellations.
This commit is contained in:
parent
be115f4c7f
commit
fa4c1152d3
@ -9,10 +9,6 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.os.IBinder;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package za.org.treehouse.hypoalarm;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@ -23,6 +24,11 @@ public class AlarmReceiver extends BroadcastReceiver {
|
||||
Boolean alarmActive = sharedPref.getBoolean(context.getString(R.string.AlarmActivePref), true);
|
||||
|
||||
if (alarmActive) {
|
||||
|
||||
// Cancel notification if it's not already cancelled.
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.cancel(AlarmNotify.notifyID);
|
||||
|
||||
// Set a grace period alarm to send SMS
|
||||
int gracePeriod = sharedPref.getInt(context.getString(R.string.GracePeriodPref), 60);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package za.org.treehouse.hypoalarm;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@ -11,6 +12,10 @@ import android.widget.Toast;
|
||||
public class CancelGraceReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
// Cancel notification if it's not already cancelled.
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.cancel(AlarmNotify.notifyID);
|
||||
|
||||
AlarmManager graceManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
Intent graceIntent = new Intent(context, GraceReceiver.class);
|
||||
PendingIntent gracePendingIntent = PendingIntent.getBroadcast(context, MainActivity.GRACE_REQUEST, graceIntent, 0);
|
||||
|
@ -3,6 +3,7 @@ package za.org.treehouse.hypoalarm;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.content.ComponentName;
|
||||
@ -114,6 +115,10 @@ public class MainActivity extends ActionBarActivity {
|
||||
editor.commit();
|
||||
|
||||
if (!b) {
|
||||
// Cancel notification if it's not already cancelled.
|
||||
NotificationManager nm = (NotificationManager) getActivity().getSystemService(NOTIFICATION_SERVICE);
|
||||
nm.cancel(AlarmNotify.notifyID);
|
||||
|
||||
// Cancel any current alarm
|
||||
alarmManager = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
|
||||
Intent alarmIntent = new Intent(getActivity(), AlarmReceiver.class);
|
||||
|
Loading…
Reference in New Issue
Block a user