B4A Library Notification Builder Library.

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
Longtime 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:

palmzac

Active Member
Licensed User
Longtime 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
Longtime 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
Longtime User
I solved. Thanks for your help !

 
Last edited:

palmzac

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


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
Longtime 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

 

palmzac

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


 

Attachments

  • Screenshot_2017-03-28-12-55-33-382_b4a.example.png
    39.2 KB · Views: 251

barx

Well-Known Member
Licensed User
Longtime User

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

Attachments

  • Heads Up.zip
    9.8 KB · Views: 269

palmzac

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

NeoTechni

Well-Known Member
Licensed User
Longtime User
What parameters exactly are needed to get the notifications to show up on a wear device?
 

delphi98

New Member
Licensed User
Longtime 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.

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).
 

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
 

jairbj

Member
Licensed User
Longtime User
Is there any way to display like a media player?

I want to make a media player app and it should be recognized by Android as media player notification.

EDIT:

I also would like to know how to make my "notification" always on top of the notification drawer (like spotify or deezer) regardless of notifications that come later.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…