Android Question Android Notification Icon Colour Problem

PJLPJLPJL

Member
Licensed User
Hi,
I've written a little app which runs as a service and puts a notification on the status bar: this shows up perfectly well when the status bar is "dark" (my normal situation).
However, if another app (eg. Facebook) changes the status bar to "light" then although all the other icons change to dark images, mine stays as a light image (white on white) and largely disappears.
My icon is a "white on transparent" image saved as a (read-only) ".ico" file in \objects\res\drawables.

This code creates the notification:
Sub Service_Start (StartingIntent As Intent)
    mVol=pl.GetVolume(pl.VOLUME_MUSIC)
    Starter.Stray.Initialize2(Starter.Stray.IMPORTANCE_LOW)
    Starter.Stray.Icon="iconsmall"
    Starter.Stray.Light=False
    Starter.Stray.Sound=False
    Starter.Stray.SetInfo("PL's Vocalise Running","Click here to terminate.",Main)
    Service.StartForeground(1,Starter.Stray)

Images show the icon on dark and light backgrounds.
Thank you for helping.
 

Attachments

  • Screenshot_20201213-162600_Firefox.jpg
    Screenshot_20201213-162600_Firefox.jpg
    82.6 KB · Views: 201
  • Screenshot_20201213-162619_Facebook.jpg
    Screenshot_20201213-162619_Facebook.jpg
    41.7 KB · Views: 208

roumei

Active Member
Licensed User
I don't know what your Starter.Stray is but here's what works for me. My icon is a PNG file (128x128) with the content in black and a transparent background. The code to create a notification:
B4X:
Sub CreateNotification (Body As String) As Notification
    Dim notification As Notification
    notification.Initialize2(notification.IMPORTANCE_LOW)
    notification.Sound = False
    notification.Vibrate = False
    notification.Icon =  "icon"
    notification.SetInfo("Recording Track", Body, Main)
    Return notification
End Sub
icon.png
 
Upvote 0
Top