B4A Library NotificationListener library (NotificationListenerService)

Status
Not open for further replies.

webkumanda

Member
Licensed User
Longtime User
Hi,

I read whatsapp or gmail first message is ok.
but second message is "NULL"

I could not solve the problem

Thanks
 

magarcan

Active Member
Licensed User
Longtime User
Just a few questions. Doew it work with Android 5? Can I also capture notification icon/image?
 

magarcan

Active Member
Licensed User
Longtime User
It should work with Android 5.

You can get the package name and then use PackageManager to get the app icon. I don't see any other way to get the notification icon.
But some apps use custom notification icons (images for example) different to app icon. That's the case I'm asking for
 

pesquera

Active Member
Licensed User
Longtime User
Hi,

I start 2 services plus this service on main App.. I want to allow the user to stop these 3 services and exit App
I noticed an strange behaviour occurs, after exiting the App.. if some notification is opened, then the App is loaded and the App icon displays on the notification área
I can see on the logs that inmediately after that the services are stopped, this notification service is started again.. Where can I take a look? thanks

I start/stop the services on the same order
on Main, Activity_Create
StartService(Service1) ' sms interceptor
StartService(Service2) ' GCM push
StartService(Service2) ' this notification service
on Main, Menu Option to exit
StopService(Service1) ' sms interceptor
StopService(Service2) ' GCM push
StopService(Service2) ' this notification service
 

pesquera

Active Member
Licensed User
Longtime User
Ok. thanks for the answer.. I solved it with a flag (GLO_AppIsOpened ) to exit the App
 

IzioSettanta

Member
Licensed User
Longtime User
hi...a question..

i try to read notification from gmail, this is the bundle:

B4X:
(Bundle) Bundle[{android.title=MARK, android.support.actionExtras={0=Bundle[EMPTY_PARCEL], 1=Bundle[EMPTY_PARCEL]},
 android.subText=mark@gmail.com, android.showChronometer=false, android.icon=2130837754, android.text=this is a sample message,
 android.progress=0, android.progressMax=0, android.showWhen=true, android.people=[Ljava.lang.String;@423f4c28,
 android.largeIcon=android.graphics.Bitmap@42207e28, android.infoText=null, android.wearable.EXTENSIONS=Bundle[mParcelledData.dataSize=1516],
 android.progressIndeterminate=false, android.scoreModified=false}]

but (only from GMAIL) when i try to get text .....this is null!!! WHY?!?!?....whatsapp, sms ..and other apps work fine! BUG?

i use this code:

B4X:
Dim jno As JavaObject = SBN.Notification
Dim extras As JavaObject = jno.GetField("extras")
        extras.RunMethod("size", Null)
            Dim title As String = extras.RunMethod("getString", Array As Object("android.title"))
            LogColor("Title = " & title, Colors.Blue)
            Dim text As String = extras.RunMethod("getString", Array As Object("android.text"))
            LogColor("text = " & text, Colors.Blue)

i use android 4.4.3 and 5.1.1
PLS HELPPPP!!!!!
 

FabioG

Active Member
Licensed User
Longtime User
Hello to all

there is a way to check if the app is already enabled on the Notification Access ?
 

wes58

Active Member
Licensed User
Longtime User
Hello to all

there is a way to check if the app is already enabled on the Notification Access ?
I am using the following code to check if the application is enabled:
B4X:
Sub CheckSettings As Boolean
    Dim ph As Phone
    Dim nstr, pstr As String
    Dim r As Reflector
    pstr = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
    nstr = ph.GetSettings("enabled_notification_listeners")
    Return nstr.Contains(pstr)
End Sub
And then, open the Settings to enable/disable it:
B4X:
Sub Button1_Click
    Dim In As Intent
    In.Initialize("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS", "")
    StartActivity(In)
End Sub
 

FabioG

Active Member
Licensed User
Longtime User

it works! thanks!
but I have to customize this code with the packagename of my app?
 

wes58

Active Member
Licensed User
Longtime User
it works! thanks!
but I have to customize this code with the packagename of my app?
pstr is the package name of your application - pstr = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")

nstr is the the string containing all applications that are enabled in Settings: nstr = ph.GetSettings("enabled_notification_listeners")

This will return true if the pstr (your package name) is part of the nstr, i.e. whether your application is enabled in Settings: Return nstr.Contains(pstr)
 

FabioG

Active Member
Licensed User
Longtime User
thanks for your reply

so, if I understand
I can change this

B4X:
pstr = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")

to

B4X:
pstr = r.GetStaticField("MY_PKG_NAME", "packageName")

right ?
 

IzioSettanta

Member
Licensed User
Longtime User
sms(text message) and whatsapp print something...gmail null, but in the "Bundle there is a text!!!

android.text=this is a sample message

bug?

i try on HTC, Samsung and other...and with a different android version 4.4--->5.1.1
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…