Because of I didn't managed it to get working b4a-library for Android 4.3 Notification_Listener_Service (NLS),
I've made a helper App complete in java:
NLSHelper.apk
This app can be installed hidden from App drawer, and it act as an Broadcast-Receiver/-Sender for using it from B4a projects.
After NLSHelper.apk is installed, it listens for Notifications from Android Notification_Listener_Service.
If an Broadcast for notification service is received this app sends a custom formatted broadcast, that can received by our b4a projects via manifest-xml-declared broadcast listener...
NLSHelper reacts on the following NLS-broadcasts by Android:
_onNotificationPosted
_onNotificationRemoved
It sends the following broadcasts to our b4a-projects:
for _onNotificationPosted:
_onNotificationRemoved:
in our manifest.xml we have to declare the broadcast-listener for those broadcasts
in this example for my servicemodule 'srvnotificationlistener':
After receiving the broadcast in b4a service module or activity we can split the Intents extras...
i.e.:
and can react in our b4a project as follows:
There are some more broadcast scenarios, that I can describe later or in sample project.
If anyone is interested in that solution, I could make a small sample project for the service...
The NLSHelper.APK ca be downloaded here: http://forum.xda-developers.com/showthread.php?t=2334221
This is my Bubble Launcher's XDA thread - Bubble Launcher uses the helper app for creating floating notifications in its user interface (there are screenshots in the xda-thread)...
BTW - Bubble Launcher itself is completely written B4A!
I've made a helper App complete in java:
NLSHelper.apk
This app can be installed hidden from App drawer, and it act as an Broadcast-Receiver/-Sender for using it from B4a projects.
After NLSHelper.apk is installed, it listens for Notifications from Android Notification_Listener_Service.
If an Broadcast for notification service is received this app sends a custom formatted broadcast, that can received by our b4a projects via manifest-xml-declared broadcast listener...
NLSHelper reacts on the following NLS-broadcasts by Android:
_onNotificationPosted
_onNotificationRemoved
It sends the following broadcasts to our b4a-projects:
for _onNotificationPosted:
B4X:
Intent i2 = new Intent("nlshelper.NLS_BR");
i2.putExtra("notification_event", "onNotificationPosted /:/" + sbn.getPackageName() + "/:/"
+ sbn.getTag() + "/:/"
+ sbn.getNotification().tickerText + "/:/"
+ sbn.getId() + "/:/"
+ sbn.getNotification().contentIntent.getIntentSender() + "/:/"
+ "0x" + Integer.toHexString(sbn.getNotification().icon) + "/:/"
+ sbn.isOngoing() + "/:/"); //sbn.getNotification().toString());
sendBroadcast(i2);
_onNotificationRemoved:
B4X:
Intent i2 = new Intent("nlshelper.NLS_BR");
i2.putExtra("notification_event","onNotificationRemoved /:/" + sbn.getPackageName() + "/:/" + sbn.getTag() + "/:/"
+ sbn.getNotification().tickerText + "/:/" + sbn.getId() + "/:/"
+ sbn.getNotification().toString());
sendBroadcast(i2);
in our manifest.xml we have to declare the broadcast-listener for those broadcasts
in this example for my servicemodule 'srvnotificationlistener':
B4X:
<receiver
android:name=".srvnotificationlistener$srvnotificationlistener_BR"
android:enabled="true">
<intent-filter>
<action android:name="nlshelper.NLS_BR" />
</intent-filter>
</receiver>
After receiving the broadcast in b4a service module or activity we can split the Intents extras...
i.e.:
B4X:
Sub Service_Start (StartingIntent As Intent)
'ToastMessageShow(StartingIntent.ExtrasToString,False)
Dim intStr,pkg,tickertext,tag,id,notify,intentSender,IconResId,onGoing,parts() As String
intStr=StartingIntent.ExtrasToString
parts=Regex.Split("/:/",intStr)
'Log(notify)
pkg=parts(1)
tag=parts(2)
tickertext=parts(3)
id=parts(4)
notify=parts(5)
Try
IconResId=parts(6)
onGoing=parts(7)
Catch
IconResId=""
onGoing=False
End Try
...
and can react in our b4a project as follows:
B4X:
If parts(0).Contains("onNotificationPosted")=True Then
'Do what ever you want here with extra's data
ElseIf parts(0).Contains("onNotificationRemoved")=TrueThen
'Do what ever you want here with extra's data
End if
There are some more broadcast scenarios, that I can describe later or in sample project.
If anyone is interested in that solution, I could make a small sample project for the service...
The NLSHelper.APK ca be downloaded here: http://forum.xda-developers.com/showthread.php?t=2334221
This is my Bubble Launcher's XDA thread - Bubble Launcher uses the helper app for creating floating notifications in its user interface (there are screenshots in the xda-thread)...
BTW - Bubble Launcher itself is completely written B4A!