C CR95 Active Member Licensed User Longtime User Oct 18, 2025 #1 I start from this sample : https://www.b4x.com/android/forum/t...er-library-notificationlistenerservice.35630/ I installed both NotificationListener library and Erel's exemple. Please note that Erel indicates that exemple was updated to support B4XPages and Android leveltargetSdkVersion=34 (#103 and #104). My configuration is B4A level 13.4 / android-36 and my Xiaomi phone is running Android 14 1°) First of all, I get an IDE error in Service_Start Sub in NotificationService B4X: Copy If listener.HandleIntent(StartingIntent) Then Return Is there an issue with the library as "listener" does not know "HandleIntent" ? 2°) If I comment this line, compilation/execution are fine BUT log contains nothing when notifications are received on the phone. FYI, manifest contains following additional lines B4X: Copy AddApplicationText( <service android:name="anywheresoftware.b4a.objects.NotificationListenerWrapper" android:label="Notification Listener" android:exported="false" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"> <intent-filter> <action android:name="android.service.notification.NotificationListenerService" /> </intent-filter> </service>) Maybe the new declarations (hereafter for the music player) for declaring a service (starting from Andoid14) should be added in the manifest ????. B4X: Copy AddPermission(android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK) SetServiceAttribute(MyMusicService, android:foregroundServiceType, "mediaPlayback") 3°) If yes, what is the type of service to declare ?
I start from this sample : https://www.b4x.com/android/forum/t...er-library-notificationlistenerservice.35630/ I installed both NotificationListener library and Erel's exemple. Please note that Erel indicates that exemple was updated to support B4XPages and Android leveltargetSdkVersion=34 (#103 and #104). My configuration is B4A level 13.4 / android-36 and my Xiaomi phone is running Android 14 1°) First of all, I get an IDE error in Service_Start Sub in NotificationService B4X: Copy If listener.HandleIntent(StartingIntent) Then Return Is there an issue with the library as "listener" does not know "HandleIntent" ? 2°) If I comment this line, compilation/execution are fine BUT log contains nothing when notifications are received on the phone. FYI, manifest contains following additional lines B4X: Copy AddApplicationText( <service android:name="anywheresoftware.b4a.objects.NotificationListenerWrapper" android:label="Notification Listener" android:exported="false" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"> <intent-filter> <action android:name="android.service.notification.NotificationListenerService" /> </intent-filter> </service>) Maybe the new declarations (hereafter for the music player) for declaring a service (starting from Andoid14) should be added in the manifest ????. B4X: Copy AddPermission(android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK) SetServiceAttribute(MyMusicService, android:foregroundServiceType, "mediaPlayback") 3°) If yes, what is the type of service to declare ?
Erel B4X founder Staff member Licensed User Longtime User Oct 19, 2025 #2 I've just downloaded the example, changed targetSdkVersion to 35 and ran it on an Android 36 device. No errors and everything seems to work properly. Upvote 0
I've just downloaded the example, changed targetSdkVersion to 35 and ran it on an Android 36 device. No errors and everything seems to work properly.
C CR95 Active Member Licensed User Longtime User Oct 19, 2025 #3 Thanks for your quick reply. I reinstalled all. YES, it works properly now on Android 9 (without additional intervention) and on Android 14. But, for Android 14, (my understanding is that) the XIAOMI phone adds an HyperOS Security system (it is its name when booting) which runs besides Android. When installing the application, it imposes the user to go not only in Notifications authorizations but also in Parameters/Applications and to authorize notifications for this particular application and also to agree to be responsible in case of security issues.... (red blinking button) Erel, I know that your time is counted but you did not answer my second question : how to run permanently this background service (as a media player or location application) with the new constraints imposed by Android 14 ? Upvote 0
Thanks for your quick reply. I reinstalled all. YES, it works properly now on Android 9 (without additional intervention) and on Android 14. But, for Android 14, (my understanding is that) the XIAOMI phone adds an HyperOS Security system (it is its name when booting) which runs besides Android. When installing the application, it imposes the user to go not only in Notifications authorizations but also in Parameters/Applications and to authorize notifications for this particular application and also to agree to be responsible in case of security issues.... (red blinking button) Erel, I know that your time is counted but you did not answer my second question : how to run permanently this background service (as a media player or location application) with the new constraints imposed by Android 14 ?
Erel B4X founder Staff member Licensed User Longtime User Oct 21, 2025 #4 CR95 said: First of all, I get an IDE error in Service_Start Sub in NotificationService Click to expand... CR95 said: Erel, I know that your time is counted but you did not answer my second question : how to run permanently this background service (as a media player or location application) with the new constraints imposed by Android 14 ? Click to expand... There are logical steps that we need to follow. If you encountered a compiler error and I'm unable to reproduce it, then this must be the first thing to check. About the background service, see tip number 1: https://www.b4x.com/android/forum/t...er-library-notificationlistenerservice.35630/ If you encountered anything concrete then please post it. Upvote 0
CR95 said: First of all, I get an IDE error in Service_Start Sub in NotificationService Click to expand... CR95 said: Erel, I know that your time is counted but you did not answer my second question : how to run permanently this background service (as a media player or location application) with the new constraints imposed by Android 14 ? Click to expand... There are logical steps that we need to follow. If you encountered a compiler error and I'm unable to reproduce it, then this must be the first thing to check. About the background service, see tip number 1: https://www.b4x.com/android/forum/t...er-library-notificationlistenerservice.35630/ If you encountered anything concrete then please post it.
C CR95 Active Member Licensed User Longtime User Oct 21, 2025 #5 There are logical steps that we need to follow. If you encountered a compiler error and I'm unable to reproduce it, then this must be the first thing to check. Click to expand... You are right. Sorry. But your intervention helped me to find that I was using a bad/old library. Thanks Upvote 0
There are logical steps that we need to follow. If you encountered a compiler error and I'm unable to reproduce it, then this must be the first thing to check. Click to expand... You are right. Sorry. But your intervention helped me to find that I was using a bad/old library. Thanks