Search code examples
push-notificationiconsandroid-5.0-lollipopanedistriqt

Distriqt push notification icon at status bar remain white at Android 5


Andorid 5 take 96px icon as default for status bar and until it is not white + aplha changel it wont display it. But 96px icon is also used for main application icon. How can I set this status bar icon to custom one?

how it look like


Solution

  • With Android 5+ you need to provide dedicated notification icons which are white/grey and transparent to fit in with the Android design guidelines. Currently there is no way to include these icons through the AIR application descriptor. Instead you have to add them as custom Android resources.

    To do this you'll need to create an icon that is only white with transparency something like the below:

    enter image description here

    Then goto the Android Asset Studio Notification Icon Generator

    https://romannurik.github.io/AndroidAssetStudio/icons-notification.html

    and upload your source image. Make sure you change the name of the icon. Take note of this name as you will be using this name to reference this icon in notifications. In the example below we used your_icon_name.

    You can then download the zip and extract the contents and you should have a series of directories containing all the different sized icons required.

    Next, download our CustomResources ANE generator script from the following repository:

    https://github.com/distriqt/ANE-CustomResources

    Follow the instructions to setup the script and then copy the contents of the zip you downloaded earlier into the res directory in the script root.

    After running the script you should have an ANE com.distriqt.CustomResources.ane that you can include in your project.

    Now you can use the name of your icon to create notifications:

    Notifications.service.notify(
        new NotificationBuilder()
            .setIcon( "your_icon_name" )
            .setAlert( "Notification Alert" )
            .setTitle( "Notification Title" )
            .setBody( "The body of the notification" )
            .build()
    );