B4A Library Notification Builder Library.

Discussion in 'Additional libraries, classes and official updates' started by barx, Mar 17, 2013.

  1. Dave O

    Dave O Active Member Licensed User

    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.
     
  2. DickD

    DickD Active Member Licensed User

    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.
     
  3. fransvlaarhoven

    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: Mar 14, 2017
  4. Erel

    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?
     
  5. fransvlaarhoven

    fransvlaarhoven Active Member Licensed User

    Yes, testing with screen off...
     
  6. Erel

    Erel Administrator Staff Member Licensed User

  7. fransvlaarhoven

    fransvlaarhoven Active Member Licensed User

  8. palmzac

    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: Mar 25, 2017
  9. barx

    barx Well-Known Member Licensed User

    Code:
    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.
     
  10. palmzac

    palmzac Active Member Licensed User

    I solved. Thanks for your help ! :)

     
    Last edited: Mar 27, 2017
    barx likes this.
  11. palmzac

    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: Mar 27, 2017
  12. barx

    barx Well-Known Member Licensed User


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

    Code:
    Dim nb As NotificationBuilder
       
        nb.Category = nb.CATEGORY_CALL
     
  13. barx

    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

    Code:
    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
     
    DonManfred and inakigarm like this.
  14. palmzac

    palmzac Active Member Licensed User

    Hi Barx,

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

    Code:
    #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 !


     

    Attached Files:

  15. barx

    barx Well-Known Member Licensed User

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

    Attached Files:

  16. palmzac

    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 !

     
  17. NeoTechni

    NeoTechni Well-Known Member Licensed User

    What parameters exactly are needed to get the notifications to show up on a wear device?
     
  18. delphi98

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

    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.
     
  20. Manolete

    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
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice