Bug? Typo in NB6 class causing erroneous channel name

Discussion in 'Bugs & wishlist' started by Sandman, Jun 1, 2018.

  1. Sandman

    Sandman Well-Known Member Licensed User

    I think there's a typo in the NB6 class, found at https://www.b4x.com/android/forum/threads/nb6-notifications-builder-class-2018.91819/#content.

    Code:
    Public Sub Initialize (ChannelId As String, ChannelName As Object, ImportanceLevel As StringAs NB6
        ctxt.InitializeContext
        PendingIntentStatic.InitializeStatic(
    "android.app.PendingIntent")
        NotificationStatic.InitializeStatic(
    "android.app.Notification")
        common.InitializeStatic(
    "anywheresoftware.b4a.keywords.Common")
        
    Dim jo As JavaObject
        SdkLevel = jo.InitializeStatic(
    "android.os.Build$VERSION").GetField("SDK_INT")
        
    If SdkLevel < 23 Then
            SupportLevel = S_OLD
        
    Else if SdkLevel >= 26 Then
            SupportLevel = S_CHANNEL
        
    Else
            SupportLevel = S_BUILDER
        
    End If
        
    If IsOld Then
            OldNotification.Initialize
            OldNotification.Icon = 
    "icon"
        
    Else if IsChannel Then
            ChannelId = ChannelId & 
    "_" & ImportanceLevel
            NotificationBuilder.InitializeNewInstance(
    "android.app.Notification$Builder"Array(ctxt, ChannelId))
            
    Dim im As Map = CreateMap("MIN"1"LOW"2"DEFAULT"3"HIGH"4)
            
    Dim i As Int = im.Get(ImportanceLevel)
            Channel.InitializeNewInstance(
    "android.app.NotificationChannel"Array(ChannelId, Application.LabelName, i))
        
    Else
            NotificationBuilder.InitializeNewInstance(
    "android.app.Notification$Builder"Array(ctxt))
            
    Dim pm As Map = CreateMap("MIN": -2"LOW": -1"DEFAULT"0"HIGH"1)
            
    Dim p As Int = pm.Get(ImportanceLevel)
            NotificationBuilder.RunMethod(
    "setPriority"Array(p))
        
    End If
        
    If ImportanceLevel = "DEFAULT" Or ImportanceLevel = "HIGH" Then
            SetDefaults(
    TrueTrueTrue)
        
    Else
            SetDefaults(
    FalseTrueTrue)
        
    End If
        
    Return Me
    End Sub
    The ChannelName is never used. Instead Application.LabelName is used as name for the channel.
     
    Erel likes this.
  2. Erel

    Erel Administrator Staff Member Licensed User

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