Android Question Notifications V6 Bug?

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Hello,

I'm having a very strange problem here... when setting a customsound in a notification using NB6, a call from some part of code runs ... from other , no sound. Exactly the same call, but from different parts of the service code. To be sure that it's running exactly the same code, from both sectors of app I call the same sub to notify (inside the same service)... see:
B4X:
Sub NotifyV6(UserImage As String,NotifyText As String)
 
    Dim Rp As RuntimePermissions
                                     
    Dim Folder As String = Rp.GetSafeDirDefaultExternal("shared")
    Dim FileName As String = "msgting.mpeg"
    Dim n As NB6
    n.Initialize("Mensagem Nexphone",Application.LabelName,"HIGH")
    n.SmallIcon(LoadBitmapResize(File.DirAssets,"logonexphone8.png",24dip,24dip,True))
    n.SetDefaults(False,True,True)
    n.AutoCancel(True)
                                     
    If File.Exists(File.DirInternal,UserImage) Then
        n.LargeIcon(NativeMe.RunMethod("getRoundBitmap",Array(LoadBitmap(File.DirInternal,UserImage))))
    Else
        n.LargeIcon(NativeMe.RunMethod("getRoundBitmap",Array(LoadBitmap(File.DirAssets,"ic_person_black_48dp.png"))))
    End If
                                     
    Dim CsUri As String = CreateFileProviderUri(Folder, FileName)
    n.CustomSound(CreateFileProviderUri(Folder, FileName))
                                                                             
    Dim Notification As Notification
    Notification.Initialize
    Notification.OnGoingEvent = False
    Notification = n.Build("Nova Mensagem",NotifyText, "", chats)
    Notification.Notify(20)
 
End Sub

The code calls: NotifyV6(param1,param2) ... from two different places of the routine. One call, custom sound ok! Other call... no sound!!!! I really don't know what is happening... crazy!
Any suggestion?

### Update...
I detected that a call to a sub in other service after the notification call is causing the sound problem ...

CallSubDelayed2(DownMediaQueue,"GetMedia",dd1)

the service that has the sub has a call to http service and a callback... maybe...

### FINAL UPDATE
The download service as a call to a classic notification when starts:
B4X:
    Dim n As Notification
    n.Initialize
    n.Icon = "icon"
    n.Vibrate = False
    n.Sound = False
    n.Light = False
    n.SetInfo("Baixando midia...", "", Target)
    Service.StartForeground(1, n)

When called, besides in other channel (1), it looks to cancel the sound of the other notification generated by NB6 class... I'll try to do an approach to check the sdk version and, if greater than 21, use the NB6 class to this call also...
Thanks everybody.
 
Last edited:

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Use different notification channels if you want to use different sounds.
I noticed this ... in Android 8 it's not possible to change notification properties after created due the notifications channel logic (the notifications are "fixed" after created and the only way to change is uninstall the app). This approach could be a little bit complicated if we want to allow the user to change the notification sound... imagine, user changes the sound of 4 notifications 5 times... 20 channels ? Crazy, but Android 8 required and Google decided... what to do?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…