Android Question Problem in NotificationBuilder icon

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
B4X:
Log(Topic & "   " &  Main.messagerecesive)
        Dim NotificationInfo As NotificationBuilder
        NotificationInfo.Initialize
        NotificationInfo.SmallIcon = "icon"
        NotificationInfo.setActivity(Main)
        NotificationInfo.ContentTitle = "LuzHor"
        NotificationInfo.ContentText = Main.messagerecesive
        NotificationInfo.DefaultSound = True
        NotificationInfo.DefaultLight = True
        NotificationInfo.DefaultVibrate = True
        'NotificationInfo.setProgress(100, 75, False)
        Dim P As Phone
        If P.SdkVersion >= 26 Then
            Dim Ctxt As JavaObject
            Ctxt.InitializeContext
 
            Dim Manager As JavaObject
            Manager.InitializeStatic("android.app.NotificationManager")
            Dim Channel As JavaObject
 
            Dim ChannelVisibleName As String = "My Channel"
            Channel.InitializeNewInstance("android.app.NotificationChannel", Array("MyChannelId1", ChannelVisibleName, Manager.GetField("IMPORTANCE_DEFAULT")))
            Manager = Ctxt.RunMethod("getSystemService", Array("notification"))
            Manager.RunMethod("createNotificationChannel", Array(Channel))
 
            Dim Jo As JavaObject = NotificationInfo
            Jo.RunMethod("setChannelId", Array("MyChannelId1"))
        End If

        NotificationInfo.Notify(1)


This is the code and I use B4A V8.0 with targetSdkVersion = "22"
My Icon
 

Attachments

  • icono.png
    icono.png
    6.2 KB · Views: 311
Last edited:
Upvote 0

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
ok I understand, I mean that just placing this code works ..
B4X:
        Dim NotificationInfo As NotificationBuilder
        NotificationInfo.Initialize
        NotificationInfo.SmallIcon = "icon"
        NotificationInfo.setActivity(Main)
        NotificationInfo.ContentTitle = "LuzHor"
        NotificationInfo.ContentText = Main.messagerecesive
        NotificationInfo.DefaultSound = True
        NotificationInfo.DefaultLight = True
        NotificationInfo.DefaultVibrate = True
 
Upvote 0

SMOOTSARA

Active Member
Licensed User
Longtime User
Hi guys :)
My app icon is completely gray.
The specifications are as follows
B4X:
phone
asuse android 7.1.1
SdkVersion >= 25
manifest
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="27"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
B4X:
android.jar:
C:\Android\platforms\android-27\android.jar
 

Attachments

  • photo_2018-04-06_16-25-20.jpg
    photo_2018-04-06_16-25-20.jpg
    133.5 KB · Views: 382
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
I think that for SmallIcon Android expects one color on transparent background. See https://romannurik.github.io/Androi...rim=1&source.space.pad=0&name=ic_stat_ac_unit
The color around icon is possible to change using something like this
B4X:
javaobjectInstance = notificationbuilderInstance
javaobjectInstance.RunMethod ("setColor", Array As Object (appcompatInstance.GetThemeAttribute ("colorAccent")))

The purpose of small icon is to show "type" of notification (like in Windows IDI_EXPLAMATION, IDI_QUESTION etc.).
If you want to show application icon there are reasons to use LargeIcon
 
Last edited:
Upvote 0
Top