akohout
akohout

Reputation: 1811

Icon problems for GCM notification build with NotificationCompat.Builder

I create push notifications as follows:

NotificationCompat.Builder notificationBuilder =
            new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.ic_launcher)
                    .setContentTitle(getString(R.string.app_name))
                    .setContentText(msg)
                    .setLights(Color.YELLOW, 250, 500)
                    .setAutoCancel(true)
                    .setVibrate(new long[] {100, 100, 100, 100})
                    .setSound(alarmSound)
                    .setPriority(NotificationCompat.PRIORITY_DEFAULT)

However, on my Nexus 5 with Android 5 I always get a mini icon instead of the launcher icon in normal size.

Solution: For Android 5 it seems to be necessary to use a transparent background with a white icon on it. Using the LargeIcon did work in the Notification Center, but not in the Status Bar.

Upvotes: 1

Views: 1164

Answers (1)

Keab42
Keab42

Reputation: 688

I believe that you also need to use setLargeIcon

If you set that to use your launcher icon then it should appear at the correct size. SmallIcon is for the icon that pops up in the status bar.

Your Launcher Icon has a Yellow Background with a white icon on it. For the Small Icon, Create a version that is just the white icon with a transparent background. Android is automatically setting all the colours in the icon file to white, which is why it appears as a big white square.

Upvotes: 1

Related Questions