Android Question App crashing when initializing a channel with the notification builder

rleiman

Well-Known Member
Licensed User
Hi Everyone,

I'm using the updated notification builder and the initialize statement is crashing my app. Does anyone know what I'm missing?

Thanks.

Code in the Process_Globals sub routine:
B4X:
    Private nBNotify As NotificationBuilder
    Private channel As NotificationChannelBuilder
Code in a sub routine to initialize objects:
B4X:
    If channel.ChannelsSupported Then
        channel.Initialize("Channel_1", "My App Name", channel.IMPORTANCE_DEFAULT)
        channel.Build
    End If

    nBNotify.Initialize("Channel_1")
 

Peter Simpson

Expert
Licensed User
Here you go...
B4X:
'Process_Globals
    Private Notification As NotificationBuilder
    Private Channel As NotificationChannelBuilder 'New object
    Private ChannelID As String = "Boo_Name" '"Channel_1"
    Private ChannelName As String = "Boo Name"

'Code in Sub
    If Channel.ChannelsSupported Then
        Channel.Initialize(ChannelID, ChannelName, Channel.IMPORTANCE_HIGH)
        Channel.EnableLights = True
        Channel.EnableVibration = True
        Channel.Build
        Notification.Initialize(Channel.ID)
    Else
        Notification.Initialize(Null)
    End If
Enjoy...
 

rleiman

Well-Known Member
Licensed User
Hi Peter,

Thanks so much for the code sample. That will help a lot. ;)

Cheers.
 
Top