Android Question Notification icon

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am trying to play a icon in the notification bar, but for some reason I can't get the icon to display.

I am using:

B4X:
n.Initialize
    n.OnGoingEvent = True
    n.Sound = False
    n.Vibrate = False
    n.Icon = "icon"
    n.SetInfo("App is running" , "tap to stop app" , Main)
    n.Notify(1)

in the Objects\res\drawable I have my icon (icon.png)

The text displays but the only the icon is not showing.

Any ideas on what I have done wrong ?
 

DonManfred

Expert
Licensed User
Longtime User
in the Objects\res\drawable I have my icon (icon.png)
and it is set to readonly to not be removed while compiling?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've tested this code in a project and it works:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   Dim n As Notification
   n.Initialize
   n.OnGoingEvent = True
   n.Sound = False
   n.Vibrate = False
   n.Icon = "icon"
   n.SetInfo("App is running" , "tap to stop app" , Me)
   n.Notify(1)
End Sub
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
This is odd.

I started a blank project and used the code from post 4.

It worked.

I then copied the icon I was using in my main app to this new project and it still worked.

I then thought there must be something in my main app that was causing it to fail.

I then started copying module by module to the new app and it still worked. I ended up copying every module (kept the same names for everything) and it still worked.

My main app is failing, but the new project is working even knowing it contains the same files & code.

Not a major thing since I have now copied everything over, but not sure what is caused this to happen and hopefully this doesn't happen again later on.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
I recently changed my notification icon and I had to do a Clean project to get the new icon to show up.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
I recently changed my notification icon and I had to do a Clean project to get the new icon to show up.
Yeah, I tried that and still had the same issue. It seems to be still working in the new project, so all good.
 
Upvote 0

Aviles

Member
Licensed User
Longtime User
Hi, I had a similar problem.

I added a second icon and I set as read-only, but when I tried to use in a notification I had the follow error:
"Invalid notification (no valid small icon)".

I followed the suggestions of this post, and it works, but If I adds another icon this doesn't work. so after try I found that If you adds a second, third, fourth icon you just only should compile your project in release mode to do it work.


after, you can change to debug mode and it will working.


Note: You should be follow the Android Icons guidelines
https://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html
 
Upvote 0
Top