👂 Notification Listener Extension [Open Source]

Description

Notification Listener Extension to listen to all notifications of your device. Packagename, title and text of all notifications will be stored in TinyDB. Also of course works if your app is not running and also survives a reboot of the device.
Minimum API level is 21 (Android 5).

Version History

Nov 8th, 2020: Version 1: initial version for App Inventor.

Aug 16th, 2022: Version 2: filter by package name added, SDK31 update: exported = "true" added in manifest for serviceelement

Aug 10th, 2023: Version 3: Google Pay fix by vknow360

Jan 20th, 2024: Version 4: replace local broadcast receiver by normal broadcast receiver by Kumaraswamy

Jan 22th, 2024: Version 5: itoo framework wrapper added by Kumaraswamy, minor improvements


For details, example project, documentation as well as the source code of the extension see here App Inventor Extensions: Notification Listener | Pura Vida Apps

Available Blocks

Unbenannt2

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

10 Likes

Tested and working on Android 7 with Google Calendar notifications (when they actually work and don't disappear after 10 seconds). Like the fact that you have a record of all the notifications that come through.

Good job :slight_smile:

1 Like

i tried this aia and it works great when i built the app but when i compile to aab then gives error. why?

Are you using App Inventor?
Did you use the example project for this?
Which error do you get?
Please provide the complete log

Taifun

yes

yes

App Inventor is unable to compile this project.
The compiler error output was
[ReadBuildInfo] Starting Task
[ReadBuildInfo] Task succeeded in 0.005 seconds
[LoadComponentInfo] Starting Task
[LoadComponentInfo] INFO: Generating assets...
[LoadComponentInfo] Component assets needed, n = 0
[LoadComponentInfo] INFO: Generating activities...
[LoadComponentInfo] Component activities needed, n = 0
[LoadComponentInfo] Component activity metadata needed, n = 0
[LoadComponentInfo] INFO: Generating broadcast receivers...
[LoadComponentInfo] Component content providers needed, n = 1
[LoadComponentInfo] INFO: Generating libraries...
[LoadComponentInfo] Libraries needed, n = 0
[LoadComponentInfo] Component metadata needed, n = 0
[LoadComponentInfo] INFO: Generating Android minimum SDK...
[LoadComponentInfo] INFO: Generating native libraries...
[LoadComponentInfo] Native Libraries needed, n = 0
[LoadComponentInfo] INFO: Generating permissions...
[LoadComponentInfo] INFO: Component "com.google.appinventor.components.runtime.Button" does not specify permissionConstraints
[LoadComponentInfo] INFO: Component "com.google.appinventor.components.runtime.Form" does not specify permissionConstraints
[LoadComponentInfo] INFO: Component "com.google.appinventor.components.runtime.HorizontalArrangement" does not specify permissionConstraints
[LoadComponentInfo] INFO: Component "com.google.appinventor.components.runtime.Label" does not specify permissionConstraints
[LoadComponentInfo] INFO: Component "com.google.appinventor.components.runtime.Notifier" does not specify permissionConstraints
[LoadComponentInfo] INFO: Component "com.google.appinventor.components.runtime.TinyDB" does not specify permissionConstraints
[LoadComponentInfo] INFO: Component "com.puravidaapps.TaifunNotificationListener.TaifunNotificationListener" does not specify permissionConstraints
[LoadComponentInfo] INFO: Component "io.shreyash.phase.Phase" does not specify permissionConstraints
[LoadComponentInfo] usesLocation = False
[LoadComponentInfo] Permissions needed, n = 3
[LoadComponentInfo] INFO: Component "com.puravidaapps.TaifunNotificationListener.TaifunNotificationListener" does not specify queries
[LoadComponentInfo] INFO: Component "io.shreyash.phase.Phase" does not specify queries
[LoadComponentInfo] Component services needed, n = 1
[LoadComponentInfo] INFO: Generating component broadcast receivers...
[LoadComponentInfo] Task succeeded in 0.006 seconds
[PrepareAppIcon] Starting Task
[PrepareAppIcon] INFO: Creating mipmap dirs...
[PrepareAppIcon] INFO: Generating icons...
[PrepareAppIcon] Generating icons for mipmap-mdpi
[PrepareAppIcon] Generating icons for mipmap-hdpi
[PrepareAppIcon] Generating icons for mipmap-xhdpi
[PrepareAppIcon] Generating icons for mipmap-xxhdpi
[PrepareAppIcon] Generating icons for mipmap-xxxhdpi
[PrepareAppIcon] Task succeeded in 0.197 seconds
[XmlConfig] Starting Task
[XmlConfig] INFO: Creating animation xml
[XmlConfig] Creating zoom_enter.xml
[XmlConfig] Creating fadeout.xml
[XmlConfig] Creating slide_v_exit.xml
[XmlConfig] Creating fadein.xml
[XmlConfig] Creating zoom_exit.xml
[XmlConfig] Creating slide_v_enter.xml
[XmlConfig] Creating zoom_exit_reverse.xml
[XmlConfig] Creating slide_v_enter_reverse.xml
[XmlConfig] Creating zoom_enter_reverse.xml
[XmlConfig] Creating slide_enter_reverse.xml
[XmlConfig] Creating slide_exit.xml
[XmlConfig] Creating hold.xml
[XmlConfig] Creating slide_enter.xml
[XmlConfig] Creating slide_v_exit_reverse.xml
[XmlConfig] Creating slide_exit_reverse.xml
[XmlConfig] INFO: Creating style xml
[XmlConfig] INFO: Creating provider_path xml
[XmlConfig] INFO: Creating network_security_config xml
[XmlConfig] INFO: Generating adaptive icon file
[XmlConfig] INFO: Generating round adaptive icon file
[XmlConfig] INFO: Generating adaptive icon background file
[XmlConfig] Task succeeded in 0.006 seconds
[CreateManifest] Starting Task
[CreateManifest] INFO: Reading project specs...
[CreateManifest] VCode: 2
[CreateManifest] VName: 2.0
[CreateManifest] Min SDK 21
[CreateManifest] INFO: Writing screen 'appinventor.ai_pralayaranjan24.nls.Screen1'
[CreateManifest] Task succeeded in 0.001 seconds
[AttachNativeLibs] Starting Task
[AttachNativeLibs] Task succeeded in 0.0 seconds
[AttachAarLibs] Starting Task
[AttachAarLibs] Task succeeded in 0.167 seconds
[AttachCompAssets] Starting Task
[AttachCompAssets] Task succeeded in 0.001 seconds
[MergeResources] Starting Task
[MergeResources] Task succeeded in 0.199 seconds
[SetupLibs] Starting Task
[SetupLibs] Task succeeded in 0.0 seconds
[RunAapt2] Starting Task
[RunAapt2] Task succeeded in 0.805 seconds
[GenerateClasses] Starting Task
[GenerateClasses] INFO: Source File: appinventor/ai_pralayaranjan24/nls/Screen1.yail
[GenerateClasses] INFO: Libraries Classpath = /tmp/kawa305650766720810879.jar:/tmp/acra-4.4.05531992142064802160.jar:/tmp/AndroidRuntime6221451630914304951.jar:/tmp/annotation1652385637574675367.jar:/tmp/appcompat1339272104265501805.jar:/tmp/asynclayoutinflater5307115701577326257.jar:/tmp/collection5411982180888530122.jar:/tmp/constraintlayout5204498005040882772.jar:/tmp/constraintlayout-solver1115882894935681140.jar:/tmp/coordinatorlayout7639631384204107979.jar:/tmp/core9219164456954826903.jar:/tmp/core-common7400940957948435402.jar:/tmp/core-runtime4301369509070043144.jar:/tmp/cursoradapter3893679691293481099.jar:/tmp/customview4909062008661895811.jar:/tmp/documentfile5427443089886066338.jar:/tmp/drawerlayout5820422758117913250.jar:/tmp/fragment4422846724383981182.jar:/tmp/interpolator5159477997240095244.jar:/tmp/legacy-support-core-ui3618540204685356637.jar:/tmp/legacy-support-core-utils6759984230785688859.jar:/tmp/lifecycle-common822774694795599921.jar:/tmp/lifecycle-livedata4508617577252735058.jar:/tmp/lifecycle-livedata-core3048567265792041931.jar:/tmp/lifecycle-runtime3942887592441388893.jar:/tmp/lifecycle-viewmodel342674581363856710.jar:/tmp/loader6615927482101003953.jar:/tmp/localbroadcastmanager3688396481627253871.jar:/tmp/print3567218350846836212.jar:/tmp/slidingpanelayout3324795198364107688.jar:/tmp/swiperefreshlayout7876615940521977196.jar:/tmp/vectordrawable5789885330862526223.jar:/tmp/vectordrawable-animated2739730586403847398.jar:/tmp/versionedparcelable2690125986283542595.jar:/tmp/viewpager5812714251638938877.jar:/tmp/1698155921349_0.5958845984869836-0/youngandroidproject/../assets/external_comps/com.puravidaapps.TaifunNotificationListener/files/AndroidRuntime.jar:/tmp/1698155921349_0.5958845984869836-0/youngandroidproject/../assets/external_comps/io.shreyash.phase/files/AndroidRuntime.jar:/tmp/1698155921349_0.5958845984869836-0/youngandroidproject/../build/classes:/tmp/android6116452977533613362.jar
(compiling appinventor/ai_pralayaranjan24/nls/Screen1.yail to appinventor.ai_pralayaranjan24.nls.Screen1)
(compiling /tmp/runtime3702797742955161491.scm to com.google.youngandroid.runtime)
[GenerateClasses] Task succeeded in 2.146 seconds
[RunMultidex] Starting Task
[RunMultidex] ERROR: DX returned an error code
[RunMultidex] Task errored in 16.017 seconds

As we can see, you modified the example

The question was, if you used the notification listener example project without modifying it... are you able to build then?

Taifun

After removing that component.. I can build.. Thanks

App Inventor Extensions: Notification Listener | Pura Vida Apps

I have created the example project in the link above and it seems the service starts
but I do not get any indication of notifications either for texts to the device or push notifications from Reolink

my desire is to see a notification from Reolink and do something.

In the Description in the link above it says
Required permissions: android.permission.BIND_NOTIFICATION_LISTENER_SERVICE
I cannot work out how to enable/turn it on/get that permission ?????

When I run the app and click Start I get a Notification access screen and select the notifications app
If I click Check it responds Service already has started
so it seems I have least started the Service

In Settings >Apps>notifications
Permissions says No permissions required
click on that and there is no option to turn anything on

Question:

how or where can I enable android.permission.BIND_NOTIFICATION_LISTENER_SERVICE

This is just for your information, you do not have to ask for that permission

Did you build the test project for your tests?
Which device are you using for your tests?

Starting with sdk33 it looks like I have to add post notifications permission... but meanwhile you can enable that manually in the settings of the app

Taifun

Thanks for the prompt reply.

Did you build the test project for your tests?

I initially did it from scratch using the image in the pdf and have just now downloaded and run the aia file, my original try did not have the filter in it. So the AIA file loads up compiles and runs but still does not see my Reolink notifications.

I tried changing the filter string to include Reolink,door, hoping that might trigger a hit but no luck.

Reolink notifications as seen on the cell phone are
Reolink 7.05am
Camera Alert
door bell has detected motion

Which device are you using for your tests? Samsung A20 Android 11

I had thought that the TaifunNotificationListener had access to the "Notifications" that are raised by the cell phone, Incoming calls, incoming Push notifications, etc, maybe I misunderstand???

My desire is to capture the Push notification from my Reolink NVR. Currently I can intercept them with a Automate for Android script but I wanted to use App Inventor rather than Automate.

Danke!

the filter is by package name, so you should add the package name of that app
let me suggest you to first try a test without filter to see if you then get a notification... this also to find out the package name... then do another test including filter

yes exactly
but you should filter correctly, else nothing will be shown

Taifun

Taifun, you said
let me suggest you to first try a test without filter to see if you then get a notification.

Well I did that and I got a list of notifications then had a text sent to the phone and triggered some reolink notifications and did a get again and neither the phone or reolink messages appeared
did a screen capture and copied some files and another get and got some more messages
still no notification for phone or reolink


I can see
keyboard
USB file transfer
Cable charging

Danke

I only see system notifications in your screenshot... what about other apps like WhatsApp etc?

How are you testing?

  1. Start the notification listener test app to start the service and move the app to the background
  2. Then receive some notifications
  3. Open the notification listener test app again and check what has been stored

I will also do some tests and add

Taifun

this permission is not required to run the service
the example app just works fine for me on Samsung Galaxy A54 running Android 13

  1. How did you set the package name filter? It looks like you are using the package name filter com.andoid.systemui...
    As test remove all filter to get all notifications. If you get that running, then filter for the package name you are interested in

Taifun

g'day,

I tried a couple of things

put the app into the background
sent some whats app messages to the phone
still got the same notifications plus another hundred or so as I had my phone on charge overnight

then changed the set TaifunNotificationListener PackageNamesFilter
build reinstall and run again

Removed the set statement completely - had no effect
put back the set statement changed the input to a sting " " - had no effect
changed the input to "test" - had no effect
put back the set statement changed the input back to txtbPackageNamesFilter Text "test" - had no effect

still only getting the android and com.android.systemmui messages

it is as if the PackageNamesFilter was set at the first succesful instance of running the program and it cannot be changed - why that would happen goodness only knows

I am very happy to continue to try and resolve this issue, but, it is not critical to what I am doing, I have an alternative method to get the notifications using Automate for IT, which sees the notification I am after and the sends a text to the phone which I then action with my MIT App Inventor app.

Danke

You can change the filter only before starting the service... while it is running to change the filter does not have any effect... you can click Check to see if the service is running

Uninstall your current version
Rebuild the test project as it is and install it
Open the app and remove all filters
Click Start, enable notification access for the app and click Allow
Close the app
Let some notifications come
Open the app and check what has been stored

Taifun

G'day,

Success

Apart form the program initially having a filter set which was blocking my messages I was focused on the Get button.

The Get button can create a huge great list of things and if the filter string is wrong then of course the messages your looking for don't appear in the list.

In my screwing around I sent a text message and it magically appeared on my phone whilst I wasn't looking as a single item, much head scratching later, I believe I now understand what is going on.

I can receive my push notifications from Reolink and will look at porting some of this app over to my alarm monitor app.

I added a few buttons to your app whilst I was testing
set filter - writes filter string to - TaifunNotificationListener PackageNamesFilter
get filter - gets TaifunNotificationListener PackageNamesFilter - writes it to results label
clearDB tag - its not needed - but I want to cleared the DB and make sure everything was new -
refresh - erases the results label

Thank you very much for your support !

Cheers

image
in the above the filter textbox had been erased and then [set] PackageNamesFilter = ""

Hello, @Taifun can you make the extension version 5 available? I downloaded AIX now, but it is version 4.

You can download the latest version of the notification listener extension in the Download section here

Taifun

I downloaded it from this link, but the download version is 4
Notif

Notif2