Bug? Can't show notification large icon with B4A 8.3 in Android 4.4 device

Discussion in 'Bugs & wishlist' started by ppgirl, Jul 3, 2018.

  1. ppgirl

    ppgirl Member Licensed User

    I update this notification code @Erel for ~8.1 android . As I test , it works right for 8.1 and 6 device , but works incorrect in Android 4.4.2 (Samsung S3 SPH-L710). The small icon (status bar) is ok but large icon show a blank.

    The example code is very simple , create a new project and paste the code to Starter service :

    Other , B4A 8.3 and updated with B4A SDK manager , use android-27\android.jar

    #Region  Service Attributes
    #StartAtBoot: False
    #ExcludeFromLibrary: 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.
        Dim Notification1 As Notification
    End Sub

    Sub Service_Create
    'This is the program entry point.
        'This is a good place to load resources that are not specific to a single activity.
    End Sub

    Sub Service_TaskRemoved
    'This event will be raised when the user removes the app from the recent apps list.
    End Sub

    'Return true to allow the OS default exceptions handler to handle the uncaught exception.
    Sub Application_Error (Error As Exception, StackTrace As StringAs Boolean
    Return True
    End Sub

    Sub Service_Start (StartingIntent As Intent)
    If Not(Notification1.IsInitialized ) Then
    "Example","Tap here to set","icon",Main,False,False)
    End If
    Service.StartForeground(1, Notification1)
    End Sub

    Sub Service_Destroy
    End Sub

    Private Sub CreateNotification(Title As String, Content As String, Icon As String, TargetActivity As Object, _
    As Boolean, Vibrate As Boolean) As Notification
    Dim p As Phone
    If p.SdkVersion >= 21 Then
    Dim nb As NotificationBuilder
            nb.DefaultSound = Sound
            nb.DefaultVibrate = Vibrate
            nb.ContentTitle = Title
            nb.ContentText = Content
            nb.SmallIcon = Icon
    If p.SdkVersion >= 26 Then
    Dim ctxt As JavaObject
    Dim manager As JavaObject
    Dim Channel As JavaObject
    Dim importance As String
    If Sound Then importance = "IMPORTANCE_DEFAULT" Else importance = "IMPORTANCE_LOW"
    Dim ChannelVisibleName As String = Application.LabelName
    "android.app.NotificationChannel", _
    Array("MyChannelId1", ChannelVisibleName, manager.GetField(importance)))
                manager = ctxt.RunMethod(
    Dim jo As JavaObject = nb
    End If
    Return  nb.GetNotification
    Dim n As Notification
            n.Sound = Sound
            n.Vibrate = Vibrate
            n.Icon = Icon
            n.SetInfo(Title, Content, TargetActivity)
    Return n
    End If
    End Sub

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    You don't need this code if you are using B4A v8+. The standard notification object will work with all versions.

    It will not set the large icon. You need to use NotificationBuilder for this.

    It is not a bug. For further discussion please start a new thread in the questions forum.
  3. ppgirl

    ppgirl Member Licensed User

    Thanks , The Erel's explanation clarify the puzzling problem.
  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