Android Question ListeningNotification does not listen

CR95

Active Member
Licensed User
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:
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:
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:
AddPermission(android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK)
SetServiceAttribute(MyMusicService, android:foregroundServiceType, "mediaPlayback")

3°) If yes, what is the type of service to declare ?
 

CR95

Active Member
Licensed User
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

Erel

B4X founder
Staff member
Licensed User
Longtime User
First of all, I get an IDE error in Service_Start Sub in NotificationService
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 ?
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

Active Member
Licensed User
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.
You are right. Sorry.
But your intervention helped me to find that I was using a bad/old library.
Thanks
 
Upvote 0
Top