Notification icon size.

barx

Well-Known Member
Licensed User
Longtime User
What size should an icon for notifications be? I had it, icon shows on status bar but not on the actual notification.

Had it working when using "icon". Then changed the apps icon and decided to create a new icon for the notification. Placed the new icon in the 'drawable' folder and changed the .icon = "icon" to the right filename. At some point during this they stopped showing. Obviously, the file is being found as it is used for the status bar. I really can't understand why it shows on status bar and not in notification list. They are both set using the .icon property.

I've tried 72 x 72, 32 x 32, 25 x 25, 22 x 22. the file is a .png.

Here are a couple of screen shots to help show the problem. I have no idea what the triangular shape shown is. At first I though it was what got show when a transparent icon was used.

Nothing special in the code really.

B4X:
Note.Icon = "noteicon"
Note.Number = NoteCount
any hints?


 

barx

Well-Known Member
Licensed User
Longtime User
yeah no worries

I've also tried following these guidelines and creating the folders and different size icons for different res's.

Status Bar Icons | Android Developers

i.e.

res\drawable-ldpi\noteicon.png (<<-- 18x318 icon)
res\drawable-mpdi\noteicon.png (<<-- 24x24 icon)
res\drawable-hpdi\noteicon.png (<<-- 36x36 icon)
res\drawable-xhpdi\noteicon.png (<<-- 48x48 icon)

even made the mistake of not making them read only and having to do them again lol
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User

I have my different sized icons in the folders drawable-small, -normal, -large, -xlarge, but when I did that I wasn't sure whether to use these size folder names or the density folder names like you did.

Does anyone know if it makes any difference?
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
I only use 1 icon myself, a 72x72, so far, on every device I've seen (phone or tablet) it looks good, same goes for the notification icon.

My 2 cents.

Yeah, that's how I was playing it NJ but once I noticed it wasn't working right and couldn't figure out why, I tried the different sized ones to try and solve the issue.

Sometimes it may not seem like it, as daft questions get asked at times, but I always try to solve my own issues before posting on here but being a relative n00b I don't usually get far lol.
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
It works fine here.

OK cheers, guess I'll have to start project again and test at each stage to see if/where it goes pear shaped. Thanks
 
Upvote 0

emer62304

New Member
Licensed User
Longtime User

i had this problem too, i used icon method before setinfo() and problem solved.
 
Last edited:
Upvote 0

svk123

Member
Licensed User
Longtime User
Did this issue get resolved? I am facing a similar problem:

B4X:
nb.Initialize
nb.Icon="iconnb"
nb.Sound=True
nb.Vibrate=False
nb.AutoCancel =True
nb.SetInfo("ClarityERP Alert","You have " & rows.Size & " new Clarity Alerts!",FAlert)
nb.Notify(1)

I have created iconnb.png file and stored it in the res\drawable folder. I have also set the property to readonly. I created iconnb to be 25x24. icon.png is larger. If i change nb.icon="icon" the icon is shown in the notification but appears zoomed. I resize icon.png and saved it as iconnb.png.
For nb.Icon="iconnb", nb.icon = 0 and for nb.Icon="icon" a number appears in the immediate window. It seems the iconnb.png is not getting recognized. Any reasons?
 
Upvote 0

Derek Johnson

Active Member
Licensed User
Longtime User
I've just hit the same problem using B4A Version 4.30. It looks as though the icon MUST be named icon.png and MUST be referred to as "icon".
The optimal icon size appears to be 64 x 64 to prevent the notification from zooming it one way or the other.

I also find that I cannot write just 'main' as the activity name. It has to be quoted ie "Main" or the compiler objects.

B4X:
    Dim n As Notification
    n.Initialize
    n.Vibrate=False
    n.Sound=False
    n.Light=False
  
    'n.Icon="icon32"  'This does not work with icon32.png!
    n.Icon="icon"   'This does work with icon.png
    n.SetInfo2(hdr,msg,"","Main")
    n.Notify(1)
 
Last edited:
Upvote 0

Derek Johnson

Active Member
Licensed User
Longtime User
You can use a different value for the icon but you need to add the icon to the res\drawable folder (and make it readonly).

You can use Main instead of "Main".

After closing B4A and restarting today, it now works. It turns out that all I needed to do was to do a "Clean Project" and recompile.


But I still can't use just main or Main as the activity name

B4A version 4.30
Parsing code. Error
Error parsing program.
Error description: Undeclared variable 'main' is used before it was assigned any value.
Occurred on line: 558
n.SetInfo2(hdr,msg,"",Main)
 

Attachments

  • upload_2015-2-15_10-12-38.png
    23.4 KB · Views: 399
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…