From 054ab6d84b9a1f7b28742afa1c01ab2ee2200469 Mon Sep 17 00:00:00 2001 From: Jens Date: Sat, 20 Mar 2021 22:49:05 +0100 Subject: [PATCH] Background location notifications in googlePlayFlavor --- app/src/apkFlavor/AndroidManifest.xml | 12 ++++ .../receivers/NotificationListener.java | 60 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 app/src/main/java/com/jens/automation2/receivers/NotificationListener.java diff --git a/app/src/apkFlavor/AndroidManifest.xml b/app/src/apkFlavor/AndroidManifest.xml index cfa13ffb..7fe8c4c7 100644 --- a/app/src/apkFlavor/AndroidManifest.xml +++ b/app/src/apkFlavor/AndroidManifest.xml @@ -62,6 +62,7 @@ + @@ -203,6 +204,17 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/jens/automation2/receivers/NotificationListener.java b/app/src/main/java/com/jens/automation2/receivers/NotificationListener.java new file mode 100644 index 00000000..1725f2a8 --- /dev/null +++ b/app/src/main/java/com/jens/automation2/receivers/NotificationListener.java @@ -0,0 +1,60 @@ +package com.jens.automation2.receivers; + +import android.annotation.SuppressLint; +import android.os.Build; +import android.service.notification.NotificationListenerService; +import android.service.notification.StatusBarNotification; + +import androidx.annotation.RequiresApi; + +@SuppressLint("OverrideAbstract") +@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2) +public class NotificationListener extends NotificationListenerService +{ + static NotificationListener instance; + + + public static boolean startNotificationListenerService() + { + if(instance == null) + instance = new NotificationListener(); + + instance.c + } + + @Override + public void onCreate() + { + super.onCreate(); + nlservicereciver = new NLServiceReceiver(); + IntentFilter filter = new IntentFilter(); + filter.addAction("com.kpbird.nlsexample.NOTIFICATION_LISTENER_SERVICE_EXAMPLE"); + registerReceiver(nlservicereciver,filter); + } + + @Override + public void onNotificationPosted(StatusBarNotification sbn) + { + super.onNotificationPosted(sbn); + } + + @Override + public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) + { + super.onNotificationPosted(sbn, rankingMap); + } + + @Override + public void onListenerConnected() + { + super.onListenerConnected(); + } + + @Override + public void onListenerDisconnected() + { + super.onListenerDisconnected(); + } + + +}