Bug? Notification icon not updating on Android 7

Kevin Golding

Member
Licensed User
Longtime User
I have a foreground service who's icon & text I update using the following code. On Android 7 (Nexus 5X, Android 7.0, Security patch level 5 Oct 2016) the same code updates the text but not the icon.

B4X:
Sub SetNotif(icon As String, message As String)
    Log("SetNotif("&icon&","&message&")")
    notif.Icon = icon
    notif.AutoCancel = False
    notif.Vibrate = False
    notif.Sound = False
    notif.SetInfo("Test Notification icon", message, Main)
    notif.Notify(1)
End Sub

I've attached a test project that shows the issue. Pressing the only button in the activity changes the notification text and icon which works on Android 6 but not Android 7.
 

Attachments

  • TestNotification.zip
    69.1 KB · Views: 183

Erel

B4X founder
Staff member
Licensed User
Longtime User
You need to initialize notif again before you change the icon:
B4X:
Sub SetNotif(icon As String, message As String)
   Log("SetNotif("&icon&","&message&")")
   notif.Initialize
   notif.Icon = icon
   notif.AutoCancel = False
   notif.Vibrate = False
   notif.Sound = False
   notif.SetInfo("Test Notification icon", message, Main)
   notif.Notify(1)
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…