Custom Android Push Notification Status Bar Icon

Hello,

I have added following to my “Corona” directory:

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

But I still get the triangle with exclamation mark in Corona Enterprise. Do we have to register the icons somewhere in the Enterprise edition?

Works fine on the normal SDK [import]uid: 66464 topic_id: 35000 reply_id: 335000[/import]

Enterprise builds don’t use those notification images. Those image files only apply to Corona Simulator builds.

When doing native Android development, Google want you to put all icons in your Android project’s “res” directory. This is important, because Google’s Android build process does code generation, creating an R.java file containing unique integer IDs to every resource your project and its library’s contain. The IDs are needed to access these resources, such as the notification icons. So, first I recommend that you learn about how Android resource handling via Google’s official documentation here…
http://developer.android.com/guide/topics/resources/overview.html

Next, to answer your question, what you need to do is override Corona’s notification icon resources with your own. First, have a look at the Corona library’s resource directory.
> ./CoronaEnterprise/Corona/android/lib/Corona/res

Every “drawable” directory under Corona’s “res” directory contains a file named “corona_statusbar_icon_default.png”. That is the image file you want to override. Please note that I’m saying “override” and not “replace” these files. You should not modify the contents of the Corona library directory.

To override these notification image files with your own, you need to set up your Android project with the same “drawable” directories under your “res” directory. Add each “IconNotification*.png” icon to their respective drawable directory by resolution and version. You also *must* rename these PNG files to “corona_statusbar_icon_default.png”.

Now, how this works is when you do an Android build, it builds your app’s libraries first and then it builds your app last. If the Android build process finds resources files having the same name between your app and its libraries, then the app’s resource files always win and will be used instead of the library’s resource. Note that this is why most 3rd party libraries prefix their resource file names using the library’s name to help avoid conflicts.

Anyways, the above is how Google wants you to handle it. It’s not a Corona thing. [import]uid: 32256 topic_id: 35000 reply_id: 139204[/import]

Also note that putting the “Icon*.png” files in your Corona directory will not replace your app icon when you are doing native Android development either. That only works for Corona Simulator builds.

The app icon needs to be under the “res” directory as well and referenced in your AndroidManifest.xml file as documented by Google here…
http://developer.android.com/guide/topics/manifest/application-element.html#icon
[import]uid: 32256 topic_id: 35000 reply_id: 139206[/import]

Thank you for the help, this did the trick :slight_smile: [import]uid: 66464 topic_id: 35000 reply_id: 139621[/import]

Enterprise builds don’t use those notification images. Those image files only apply to Corona Simulator builds.

When doing native Android development, Google want you to put all icons in your Android project’s “res” directory. This is important, because Google’s Android build process does code generation, creating an R.java file containing unique integer IDs to every resource your project and its library’s contain. The IDs are needed to access these resources, such as the notification icons. So, first I recommend that you learn about how Android resource handling via Google’s official documentation here…
http://developer.android.com/guide/topics/resources/overview.html

Next, to answer your question, what you need to do is override Corona’s notification icon resources with your own. First, have a look at the Corona library’s resource directory.
> ./CoronaEnterprise/Corona/android/lib/Corona/res

Every “drawable” directory under Corona’s “res” directory contains a file named “corona_statusbar_icon_default.png”. That is the image file you want to override. Please note that I’m saying “override” and not “replace” these files. You should not modify the contents of the Corona library directory.

To override these notification image files with your own, you need to set up your Android project with the same “drawable” directories under your “res” directory. Add each “IconNotification*.png” icon to their respective drawable directory by resolution and version. You also *must* rename these PNG files to “corona_statusbar_icon_default.png”.

Now, how this works is when you do an Android build, it builds your app’s libraries first and then it builds your app last. If the Android build process finds resources files having the same name between your app and its libraries, then the app’s resource files always win and will be used instead of the library’s resource. Note that this is why most 3rd party libraries prefix their resource file names using the library’s name to help avoid conflicts.

Anyways, the above is how Google wants you to handle it. It’s not a Corona thing. [import]uid: 32256 topic_id: 35000 reply_id: 139204[/import]

Also note that putting the “Icon*.png” files in your Corona directory will not replace your app icon when you are doing native Android development either. That only works for Corona Simulator builds.

The app icon needs to be under the “res” directory as well and referenced in your AndroidManifest.xml file as documented by Google here…
http://developer.android.com/guide/topics/manifest/application-element.html#icon
[import]uid: 32256 topic_id: 35000 reply_id: 139206[/import]

Thank you for the help, this did the trick :slight_smile: [import]uid: 66464 topic_id: 35000 reply_id: 139621[/import]

@Joshua Quick I know this is an old topic, but I’m running into a similar though slightly different issue which I’m hoping you can help with.

My icons are called “icon.png”, and my notification icons are called “corona_statusbar_icon_default.png”. These are both working fine, and are in folders with the following names:

drawable

drawable-hdpi

drawable-hdpi-v9

drawable-hdpi-v11

drawable-ldpi

drawable-ldpi-v9

drawable-ldpi-v11

drawable-mdpi

drawable-mdpi-v9

drawable-mdpi-v11

drawable-xhdpi

drawable-xhdpi-v9

drawable-xhdpi-v11

drawable-xxhdpi

drawable-xxhdpi-v9

drawable-xxhdpi-v11

drawable-xxxhdpi

drawable-xxxhdpi-v9

drawable-xxxhdpi-v11

Firstly, is the v9 / v11 stuff still necessary? We were talking with a publisher who say that they don’t usually have these folders, and I don’t see a mention of them in Google’s guidelines: http://developer.android.com/design/style/iconography.html

Secondly, there is another type of icon “Small Contextual Icon” which is referenced in the above link and also here:

http://iconhandbook.co.uk/reference/chart/android/

How would I go about adding those to an Android project? The existing icons were set already in place for the most part by Corona so I’m not too sure. To be honest, I’m not sure if we even need them but the publisher we spoke to said they were expecting those files in our res folder. If they are only used in certain circumstances and we do not trigger any of those circumstances then I guess it’s fine to leave them out. As far as I can make out, they are only needed in a context menu.

Thanks

Alan,

The minimum Android version Corona supports is 2.3.3, which is Android API Level 9.  This means you *should* support both the v9 and v11 icon set.  How it works is if the device you are running on is API Level 11 (Android 3.0) or higher, then your app will use the v11 icon set.  If the device you are running on is API Level 9 or 10 (Android 2.3.x), then it’ll use the v9 icon set.  The un-versioned icon set will be used on API Level 8 (Android 2.2) or lower, but Corona no longer supports those older Android versions and we’re just keeping these icons for legacy purposes.

Now, if you do not want to support Android 2.3 anymore and you bump up your “minSdkVersion” in your AndroidManifest.xml file to API Level 11, then yes, you only need to support that one v11 icon set.

Regarding contextual icons, I’m pretty sure those are intended to be displayed within the app, such as Android’s native equivalent of a TableView, and not within the notification.  Google shows an example of this within their gmail app here…

   http://developer.android.com/design/style/iconography.html#small-contextual

That said, yes, Android’s notification system is much more powerful and capable than iOS’ and Corona does not expose all of its capabilities.  The reason is to keep our notification APIs as cross-platform as possible.  However, we do have some undocumented/experimental features on Android that let you set the a badge “number” on each notification, as well being able to set the title and message separately.  Have a look here…

   http://forums.coronalabs.com/topic/34331-custom-android-notifications/?p=181751

@Joshua Quick I know this is an old topic, but I’m running into a similar though slightly different issue which I’m hoping you can help with.

My icons are called “icon.png”, and my notification icons are called “corona_statusbar_icon_default.png”. These are both working fine, and are in folders with the following names:

drawable

drawable-hdpi

drawable-hdpi-v9

drawable-hdpi-v11

drawable-ldpi

drawable-ldpi-v9

drawable-ldpi-v11

drawable-mdpi

drawable-mdpi-v9

drawable-mdpi-v11

drawable-xhdpi

drawable-xhdpi-v9

drawable-xhdpi-v11

drawable-xxhdpi

drawable-xxhdpi-v9

drawable-xxhdpi-v11

drawable-xxxhdpi

drawable-xxxhdpi-v9

drawable-xxxhdpi-v11

Firstly, is the v9 / v11 stuff still necessary? We were talking with a publisher who say that they don’t usually have these folders, and I don’t see a mention of them in Google’s guidelines: http://developer.android.com/design/style/iconography.html

Secondly, there is another type of icon “Small Contextual Icon” which is referenced in the above link and also here:

http://iconhandbook.co.uk/reference/chart/android/

How would I go about adding those to an Android project? The existing icons were set already in place for the most part by Corona so I’m not too sure. To be honest, I’m not sure if we even need them but the publisher we spoke to said they were expecting those files in our res folder. If they are only used in certain circumstances and we do not trigger any of those circumstances then I guess it’s fine to leave them out. As far as I can make out, they are only needed in a context menu.

Thanks

Alan,

The minimum Android version Corona supports is 2.3.3, which is Android API Level 9.  This means you *should* support both the v9 and v11 icon set.  How it works is if the device you are running on is API Level 11 (Android 3.0) or higher, then your app will use the v11 icon set.  If the device you are running on is API Level 9 or 10 (Android 2.3.x), then it’ll use the v9 icon set.  The un-versioned icon set will be used on API Level 8 (Android 2.2) or lower, but Corona no longer supports those older Android versions and we’re just keeping these icons for legacy purposes.

Now, if you do not want to support Android 2.3 anymore and you bump up your “minSdkVersion” in your AndroidManifest.xml file to API Level 11, then yes, you only need to support that one v11 icon set.

Regarding contextual icons, I’m pretty sure those are intended to be displayed within the app, such as Android’s native equivalent of a TableView, and not within the notification.  Google shows an example of this within their gmail app here…

   http://developer.android.com/design/style/iconography.html#small-contextual

That said, yes, Android’s notification system is much more powerful and capable than iOS’ and Corona does not expose all of its capabilities.  The reason is to keep our notification APIs as cross-platform as possible.  However, we do have some undocumented/experimental features on Android that let you set the a badge “number” on each notification, as well being able to set the title and message separately.  Have a look here…

   http://forums.coronalabs.com/topic/34331-custom-android-notifications/?p=181751