B4A Library Notification Builder Library.

Dave O

Active Member
Licensed User
I tried to add the android-support-v4.jar to the additional library folder but can not find this file anywhere. Apparently the latest version of Android SDK no longer uses this file.
In the Android SDK Manager, at the bottom under Extras, do you have the "Android Support Library" installed?

I'm not sure if my android-support-v4.jar is from that or from an earlier manual copy/paste-file action I took. Mine is dated Apr 26 2016, if that helps.
 

DickD

Active Member
Licensed User
V7 of what? That's not a versoin of B4A, Android Studio or Sdk. I'm using Java v8.
I discovered that the line needs to be added to the attributes section of the app and not to the manifest file as per the instructions for B4A 6+ But I also discovered that DefaultLight and setCustomLight DO NOT work to turn on the light on the 3 phones I tested.
 

fransvlaarhoven

Active Member
Licensed User
Hello,

I have an application running on Samsung Galaxy S7edge.

When the phone was running Android 6, setting nb.SetCustomLight(Colors.Blue, 50, 1950) worked fine.

Now the phone is updated to Android 7.0 and the notification led stopped working.

What is going wrong?

update:

when I do:
nb.DefaultLight= True
nb.DefaultVibrate= False
nb.DefaultSound= True

the led is blinking

however:
nb.DefaultLight= True
nb.DefaultVibrate= False
nb.DefaultSound= False

and no led is blinking!!!

It seems to be that switching off the sound also switches off the led?
 
Last edited:

Erel

Administrator
Staff member
Licensed User
Please use [code]code here...[/code] tags when posting code.

Are you testing it with the screen turned off?
 

palmzac

Active Member
Licensed User
Hi,

How to make 'Heads-up Notification' ?
And, I want to set the Priority to HIGH. ( like notificationBuilder.setPriority(Notification.PRIORITY_HIGH); ) How to do that ? Thank for your help !
 
Last edited:

barx

Well-Known Member
Licensed User
Hi,

How to make 'Heads-up Notification' ?
And, I want to set the Priority to HIGH. ( like notificationBuilder.setPriority(Notification.PRIORITY_HIGH); ) How to do that ? Thank for your help !
B4X:
Dim nb As NotificationBuilder

nb.Priority =
Then after the "=" use one of the following numbers

PRIORITY_MIN = -2
PRIORITY_LOW = -1
PRIORITY_DEFAULT = 0
PRIORITY_HIGH = 1
PRIORITY_MAX = 2

If I manage to do an update to the library I will add the values as CONSTANTS.

There appears to be a lot of notification changes coming in Android 'O' so that may be the time to update.
 

palmzac

Active Member
Licensed User
I solved. Thanks for your help ! :)

B4X:
Dim nb As NotificationBuilder

nb.Priority =
Then after the "=" use one of the following numbers

PRIORITY_MIN = -2
PRIORITY_LOW = -1
PRIORITY_DEFAULT = 0
PRIORITY_HIGH = 1
PRIORITY_MAX = 2

If I manage to do an update to the library I will add the values as CONSTANTS.

There appears to be a lot of notification changes coming in Android 'O' so that may be the time to update.
 
Last edited:

palmzac

Active Member
Licensed User
Hi Brax,

I trying to find a way to show a persistent heads-up notification. ( exactly like receiving a phone call or hangouts call. )

I found a solution on stackoverflow.

1. set ongoing flag to true
2. set full screen intent
3. set priority to PRIORITY_HIGH
4. set category to CATEGORY_CALL

How to setCategory in this library ? Is it possible now ? Thanks !
 
Last edited:

barx

Well-Known Member
Licensed User
Hi Brax,

I trying to find a way to show a persistent heads-up notification. ( exactly like receiving a phone call or hangouts call. )

I found a solution on stackoverflow.

1. set ongoing flag to true
2. set full screen intent
3. set priority to PRIORITY_HIGH
4. set category to CATEGORY_CALL

How to setCategory in this library ? Is it possible now ? Thanks !

I haven't looked into creating a Heads-up, but to answer your question

B4X:
    Dim nb As NotificationBuilder
   
    nb.Category = nb.CATEGORY_CALL
 

barx

Well-Known Member
Licensed User
OK, I just had a quick look at what is needed for Heads Up. The important thing seems to be the priority and having sound or vibrate active. Also, the idea of heads up is for quick interaction so an Action or 2 is advised (nut it also seems to work without). Now, I quickly put together a small project with this code

B4X:
Sub Globals
  
    Dim nb As NotificationBuilder
  
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
  
    nb.Initialize
    nb.SmallIcon = "icon"
    nb.ContentTitle = "Heads UP!"
    nb.ContentText = "B4A is about."
    nb.Priority = 1
    nb.setActivity(Me)
    nb.AddAction("arrow", "Reply", "Reply", Me) 'gfx are just some I had to hand, not much time to find others
    nb.AddAction("circle", "Dismiss", "Dismiss", Me)
  
    nb.Notify(1)
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    nb.Cancel(1)
End Sub
Lo and behold

Screen.png
 

palmzac

Active Member
Licensed User
Hi Barx,

Sorry for my stupid !
First, I cannot get a same result. Now, I attach a screen capture.

B4X:
#Region  Project Attributes 
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName: 
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
   
    #additionaljar: com.android.support:support-v4
       
#End Region

#Region  Activity Attributes 
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Dim nb As NotificationBuilder
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")

    nb.Initialize
    nb.SmallIcon = "icon"
    nb.ContentTitle = "Heads UP!"
    nb.ContentText = "B4A is about."
    nb.Priority = 1
    nb.setActivity(Me)
    nb.AddAction("icon", "Reply", "Reply", Me) 'gfx are just some I had to hand, not much time to find others
    nb.AddAction("icon", "Dismiss", "Dismiss", Me)
    nb.Notify(1)
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
    nb.Cancel(1)
End Sub
Second, I want to execute the 'heads-up notification' in service module. How to modify your example ? ( e.g. ignore the 'setActivity', Change 'Action' to 'Action2' )

Thanks !


OK, I just had a quick look at what is needed for Heads Up. The important thing seems to be the priority and having sound or vibrate active. Also, the idea of heads up is for quick interaction so an Action or 2 is advised (nut it also seems to work without). Now, I quickly put together a small project with this code

B4X:
Sub Globals
 
    Dim nb As NotificationBuilder
 
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
 
    nb.Initialize
    nb.SmallIcon = "icon"
    nb.ContentTitle = "Heads UP!"
    nb.ContentText = "B4A is about."
    nb.Priority = 1
    nb.setActivity(Me)
    nb.AddAction("arrow", "Reply", "Reply", Me) 'gfx are just some I had to hand, not much time to find others
    nb.AddAction("circle", "Dismiss", "Dismiss", Me)
 
    nb.Notify(1)
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    nb.Cancel(1)
End Sub
Lo and behold

View attachment 54176
 

Attachments

barx

Well-Known Member
Licensed User
Hi Barx,

Sorry for my stupid !
First, I cannot get a same result. Now, I attach a screen capture.

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
  
    #additionaljar: com.android.support:support-v4
      
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Dim nb As NotificationBuilder
  
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")

    nb.Initialize
    nb.SmallIcon = "icon"
    nb.ContentTitle = "Heads UP!"
    nb.ContentText = "B4A is about."
    nb.Priority = 1
    nb.setActivity(Me)
    nb.AddAction("icon", "Reply", "Reply", Me) 'gfx are just some I had to hand, not much time to find others
    nb.AddAction("icon", "Dismiss", "Dismiss", Me)
    nb.Notify(1)
  
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
    nb.Cancel(1)
End Sub
Second, I want to execute the 'heads-up notification' in service module. How to modify your example ? ( e.g. ignore the 'setActivity', Change 'Action' to 'Action2' )

Thanks !
Interesting. Try the apk from my project to see if the actions show
 

Attachments

palmzac

Active Member
Licensed User
Hi Barx,


I solved. It is china brand mobile problem. Everything is OK when I used your apk in samsung device.

Would you give me a same-function example of service module ? Thanks !

Interesting. Try the apk from my project to see if the actions show
 

delphi98

New Member
Licensed User
I can't find android-support-v4.jar in the Android SDK folder(s).

So I load the SDK Manager and scroll down to Extras. "Android Support Library" is not listed.
upload_2017-6-18_1-59-54.png
There is, however, "Android Support Repositary", but still no android-support-v4.jar on the drive.

Any ideas of where to get this file.

BTW currently using B4A 3.80 (Yes I know it is old).
 

Erel

Administrator
Staff member
Licensed User
Google has changed Android SDK structure. I recommend you to update to B4A v6+. Your other option is to find an old copy of android-support-v4.jar.
 

Manolete

Member
Licensed User
Hi,
I am facing this issues:
When the app is not in the foreground the notification Actions are not shown, but the ContentTitle and ContentText are shown correctly.
When the app is in the foreground the notification Action is shown correctly, but the ContentText and ContentTitle are not shown.

The info(ContentTitle and ContentText) comes from a Firebase Notification

Any suggeetions are really appreciated.

Regards,
Manolete
 
Top