Custom icon for local notifications in Android

Hi,

I love that we now have local notification support for Android! Walter’s blog mentioned that in Android, we can use custom icons for the notification that appears in the notification tray.

Question – how do we specify the custom icon? The documentation at http://docs.coronalabs.com/api/library/system/scheduleNotification.html doesn’t say.

Thanks in advance,
Alex [import]uid: 92621 topic_id: 33642 reply_id: 333642[/import]

I second that… I was wondering that to.

We could use these local notifications to set up a type of push notification system for our apps. Run process in background, poll website… etc

Not the most ideal way obviously… but I’ve given up on GCM ever being integrated…
but ya… Custom Icons [import]uid: 55582 topic_id: 33642 reply_id: 133881[/import]

I apologize. We haven’t had time to document this yet. This is something that we were planning on doing once we’ve finished adding push notifications.

You can set up your own custom notification icon in a Corona project by adding the following files to the root of the project directory, like how you do it for application icons.

IconNotificationDefault-ldpi.png
IconNotificationDefault-ldpi-v9.png
IconNotificationDefault-ldpi-v11.png
IconNotificationDefault-mdpi.png
IconNotificationDefault-mdpi-v9.png
IconNotificationDefault-mdpi-v11.png
IconNotificationDefault-hdpi.png
IconNotificationDefault-hdpi-v9.png
IconNotificationDefault-hdpi-v11.png
IconNotificationDefault-xhdpi.png
IconNotificationDefault-xhdpi-v9.png
IconNotificationDefault-xhdpi-v11.png

Please note that different Android OS versions support different notification icon themes. You must support them all or else your app may get rejected during the app review process.

The “-v9” indicates that the PNG file represents an Android 2.3 icon. These icons are expected to be grey.
The “-v11” indicates that the PNG file represents an Android 3.0 or higher icon. These icons are expected to be white.
Icons without the postfix “-v” are used on Android 2.2. These icons are expected to be black.

See the link below for Google’s official documentation on status bar icon sizes and theming.
http://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html

I hope this helps! [import]uid: 32256 topic_id: 33642 reply_id: 134069[/import]

Joshua,

Thankyou… I know all about the sizing and whatnot already but the link for everybody else is great.

Steve [import]uid: 55582 topic_id: 33642 reply_id: 134072[/import]

Thanks Joshua, we’ll try it! [import]uid: 92621 topic_id: 33642 reply_id: 134075[/import]

I second that… I was wondering that to.

We could use these local notifications to set up a type of push notification system for our apps. Run process in background, poll website… etc

Not the most ideal way obviously… but I’ve given up on GCM ever being integrated…
but ya… Custom Icons [import]uid: 55582 topic_id: 33642 reply_id: 133881[/import]

I apologize. We haven’t had time to document this yet. This is something that we were planning on doing once we’ve finished adding push notifications.

You can set up your own custom notification icon in a Corona project by adding the following files to the root of the project directory, like how you do it for application icons.

IconNotificationDefault-ldpi.png
IconNotificationDefault-ldpi-v9.png
IconNotificationDefault-ldpi-v11.png
IconNotificationDefault-mdpi.png
IconNotificationDefault-mdpi-v9.png
IconNotificationDefault-mdpi-v11.png
IconNotificationDefault-hdpi.png
IconNotificationDefault-hdpi-v9.png
IconNotificationDefault-hdpi-v11.png
IconNotificationDefault-xhdpi.png
IconNotificationDefault-xhdpi-v9.png
IconNotificationDefault-xhdpi-v11.png

Please note that different Android OS versions support different notification icon themes. You must support them all or else your app may get rejected during the app review process.

The “-v9” indicates that the PNG file represents an Android 2.3 icon. These icons are expected to be grey.
The “-v11” indicates that the PNG file represents an Android 3.0 or higher icon. These icons are expected to be white.
Icons without the postfix “-v” are used on Android 2.2. These icons are expected to be black.

See the link below for Google’s official documentation on status bar icon sizes and theming.
http://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html

I hope this helps! [import]uid: 32256 topic_id: 33642 reply_id: 134069[/import]

Joshua,

Thankyou… I know all about the sizing and whatnot already but the link for everybody else is great.

Steve [import]uid: 55582 topic_id: 33642 reply_id: 134072[/import]

Thanks Joshua, we’ll try it! [import]uid: 92621 topic_id: 33642 reply_id: 134075[/import]

mis posted here. deleted. [import]uid: 169919 topic_id: 33642 reply_id: 140960[/import]

mis posted here. deleted. [import]uid: 169919 topic_id: 33642 reply_id: 140960[/import]

Docs say ldpi is generated automatically (1/2 of 48x48) and no longer required. Maybe skip that check in Corona’s Build For Android?

Corona still supports older Android 2.2 devices.  While ldpi devices are rarer now days, they’re still out there.  So, yes, I still recommend that you create an ldpi icon.

Docs say ldpi is generated automatically (1/2 of 48x48) and no longer required. Maybe skip that check in Corona’s Build For Android?

Corona still supports older Android 2.2 devices.  While ldpi devices are rarer now days, they’re still out there.  So, yes, I still recommend that you create an ldpi icon.

can you please specify  the size of each one of those notifications icon?
please dont give me a link just the size of each version IconNotificationDefault,

thanks a lot.

Hi @madsheepgames,

Google doesn’t make it very obvious, honestly. As far as I can tell, they say 24x24, but that doesn’t seem correct. 48x48 would make more sense, and echo what @henrik5 says above.

Perhaps you’ll get more insight out of their documentation than I can…

http://developer.android.com/design/style/iconography.html

Best regards,

Brent

Google defines the notification icons sizes and themes.  So, I highly recommend that you take the time to read their documentation.  But that said…

The Android 3.0 and higher “-v11” icons should be set up as…

  • Must have a 2 pixel margin

  • Must be themed white

  • ldpi:  18x18 pixels

  • mdpi:  24x24 pixels

  • hdpi:  36x36 pixels

  • xhdpi:  48x48 pixels

  • xxhdpi:  72x72 pixels

The Android 2.3 “-v8” icons should be set up as…

  • Must be themed grey.

  • ldpi:  12x19 pixel PNG, but the icon should be 12x12, centered vertically.

  • mdpi:  16x25 pixel PNG, but the icon should be 16x16, centered vertically.

  • hdpi:  24x38 pixel PNG, but the icon should be 24x24, centered vertically.

  • xhpdi:  Not defined by Google.  I recommend that you use your hdpi v8 icon.

  • xxhpdi:  Not defined by Google.  I recommend that you use your hdpi v8 icon.

- Note that these icons do not have a horizontal margin.  Only a vertical margin.

The Android 2.2 icons (no “-v” postfixing) should be set up as…

  • Must have a 2 pixel margin

  • Must be themed black.  (These devices have a white status bar.)

  • ldpi:  19x19 pixels

  • mdpi:  25x25 pixels

  • hdpi:  38x38 pixels

- xhdpi:  Not defined by Google, but I recommend 50x50 pixels

  • xxhdpi:  Not defined by Google, but I recommend 75x75 pixels

Oh, and regarding the 24x24 pixel size not making sense.  That’s the size of the icon at the mdpi 1x scaling.  So, for an hdpi resolution device which uses a 1.5x scale, then icon size would be 36x36 pixels.  That is, 24 * 1.5 = 36.  Google documents this at the top of their Iconography documentation along with what the scales are for every DPI that they support.

Unfortunately, Google threw away their documentation for Android 2.2 and 2.3 notification/status-bar icons.  But I’ve posted what they should be just above.  Also, a quick Google search would find this information too.

Hi @JoshuaQuick,

Thank you so much for the fast response

this will help me a lot.

Greetings,