diff --git a/src/main/java/com/notificationFramework/notification/Notification.java b/src/main/java/com/notificationFramework/notification/Notification.java index 008e4178e2100bd2d8fa0df1783b142a989f722f..982c28b7fa04465ae5d6ed765c3df10f19744283 100644 --- a/src/main/java/com/notificationFramework/notification/Notification.java +++ b/src/main/java/com/notificationFramework/notification/Notification.java @@ -16,6 +16,8 @@ import com.notificationFramework.sedentary.frontEnd.NotificationClicked; import com.notificationFramework.sedentary.frontEnd.R; import com.notificationFramework.sedentary.frontEnd.SaveFile; +import java.util.Random; + /** * Created by Peter De Jonckheere on 09/01/2018. * <p> @@ -36,7 +38,7 @@ public abstract class Notification extends Service { /** * Arbitrary integer for the id of the notification */ - protected int snId = 0; + protected int snId = this.getResources().getInteger(R.integer.notf_id); /** * Instance of SharedPreferences which allows access to information saved in * sedentary.FrontEnd.Settings needed to determine the properties of the notification to diff --git a/src/main/java/com/notificationFramework/sedentary/frontEnd/DataAnalysis.java b/src/main/java/com/notificationFramework/sedentary/frontEnd/DataAnalysis.java index 3d3f0824269c15675334f75d6172310c3834635f..05c2f44dee23a39c385746d46c7d6bc1097f59d3 100644 --- a/src/main/java/com/notificationFramework/sedentary/frontEnd/DataAnalysis.java +++ b/src/main/java/com/notificationFramework/sedentary/frontEnd/DataAnalysis.java @@ -1,5 +1,6 @@ package com.notificationFramework.sedentary.frontEnd; +import android.app.NotificationManager; import android.content.Context; import android.content.SharedPreferences; import android.util.Log; @@ -27,7 +28,12 @@ public class DataAnalysis { } compCal.add(Calendar.MINUTE, -6); if (compCal.before(cal.getTime())) { - //Remove notification + NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + try { + nm.cancel(context.getResources().getInteger(R.integer.notf_id)); + } catch(NullPointerException e){ + Log.i("NOTIFICATION", "NOTIFICATION WAS CLICKED ON"); + } //Give new notification saying well done? logAcknowledgement(context); return true; diff --git a/src/main/res/values/integers.xml b/src/main/res/values/integers.xml index b5af0fe32e845a9ec42bb34dfe98c3c495f5f3b4..ecb73a5acbf1774912ab1e3319643a07f16261c2 100644 --- a/src/main/res/values/integers.xml +++ b/src/main/res/values/integers.xml @@ -4,4 +4,5 @@ <integer name="notify_period_minutes">60</integer> <integer name="step_job">1</integer> <integer name="alarm_rc">23</integer> + <integer name="notf_id">1240</integer> </resources> \ No newline at end of file diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 4698da2bfec96f917acb63fb00f4d08b58b7be2e..b61536115374417629650ddd2debcf6210800555 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -46,4 +46,5 @@ <string name="ack_total">Acknowledgement Total</string> <string name="ack_days">Acknowledgement Day Count</string> <string name="avg_ack">Acknowledgements per day</string> + <string name="notf_id">Notification ID</string> </resources>