Android Question AutomaticForegroundMode without vibrating and notification sound

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

Can we tell this statement not to vibrate the phone and not have a notification sound? Most of our customers don't want it to do that.

I also noticed the statement also displays the name of the app as defined in
#ApplicationLabel. Can we put custom text in the title and description areas of the notification that is displayed like we can do with a notification object?

Thanks.

B4X:
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS
 

gravel

Member
Licensed User
Longtime User
I'm using the updated version of NotificationBuilder library and this seems to work.
B4X:
    Dim channel As NotificationChannelBuilder
    If channel.ChannelsSupported = True Then
        channel.Initialize("Status updates", "Status updates", channel.IMPORTANCE_LOW)
        channel.EnableLights = False
        channel.EnableVibration = False
        channel.Build
    End If   
    NB1.Initialize("Status updates")
    NB1.smallIcon="notify"
    NB1.AutoCancel = False
    NB1.OnGoingEvent = True   
    NB1.DefaultLight = False
    NB1.DefaultSound = False
    NB1.DefaultVibrate = False       
    NB1.ContentTitle = "Custom title"
    NB1.ContentText = "Custom text"       
    NB1.setActivity(Main)
    Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS
    Service.AutomaticForegroundNotification = NB1.GetNotification
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Gravel,

Thanks for the reply and coding sample. That will help a lot! ;)

I will also see if there is a NotificationBuilder tutorial on the library so I can learn more about it.
 
Upvote 0
Top