0

I have used this code

private void sendNotification() {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();

        StrictMode.setThreadPolicy(policy);
        Intent intent = new Intent(this, LoginActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        int randomNumber = (int) System.currentTimeMillis();
        PendingIntent pendingIntent = PendingIntent.getActivity(this, randomNumber, intent,
                PendingIntent.FLAG_ONE_SHOT);

        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.BigPictureStyle nbs = new android.support.v7.app.NotificationCompat.BigPictureStyle();
        nbs.setSummaryText("Big Message").bigPicture(BitmapFactory.decodeResource(getResources(),R.drawable.general_push)).setBigContentTitle("Big Title");
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setContentTitle("Small Title")
                .setStyle(nbs)
                .setContentText("Small Message")
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);

        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            notificationBuilder.setSmallIcon(R.drawable.notif_trans);
        }else{
            notificationBuilder.setSmallIcon(R.drawable.notif_logo);
        }
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        notificationManager.notify(randomNumber, notificationBuilder.build());
    }

In my lollipop device I tested icon is coming but it is in white color only, somebody told that have to add setColorFilter I don't know how to set to app icon,I am directly setting smallIcon with drawable ID, where I have to set setColorFilter? Please help me. Some body has given this code

if (entry.targetSdk >= Build.VERSION_CODES.LOLLIPOP) {
    entry.icon.setColorFilter(mContext.getResources().getColor(android.R.color.white));
} else {
    entry.icon.setColorFilter(null);
},

in this what is entry.icon how we will get and how to set that to the small icon

Hanuman
  • 958
  • 13
  • 35
  • 1
    http://stackoverflow.com/questions/28387602/notification-bar-icon-turns-white-in-android-5-lollipop/28387744 – Robert Estivill Aug 05 '16 at 08:06
  • @RobertEstivill I used same thing I have two icons for notif trans is transparent image, but this only with orange color, but it is showing only white color(forground color) – Hanuman Aug 05 '16 at 08:08
  • Is not a matter of the icon color, is a matter of lollipop tinting your icons to white if you app is targeting deteminate sdk version. Read the linked answer – Robert Estivill Aug 05 '16 at 09:03
  • I have a problem with icon color it is showing only white color – Hanuman Aug 05 '16 at 09:16

1 Answers1

0

See below link:

Notification bar icon turns white in Android 5 Lollipop

You have to make icon in only white color and set that icon when android version is lollipop and above.

Community
  • 1
  • 1
Kinal Mer
  • 81
  • 1
  • 6
  • So if the icon with different color, like what's app icon will be green, so that will also comes in white color, no Know? – Hanuman Aug 05 '16 at 09:13
  • Yes. In lollipop and above version all applications' notification icon is in white. – Kinal Mer Aug 05 '16 at 09:35
  • but i have given with different color, even that time also it will change into white color, so how can i change that color(app icon) is there any way – Hanuman Aug 05 '16 at 09:46
  • There is no option for colored notification icon in lollipop and above. You have to set white icon. – Kinal Mer Aug 05 '16 at 09:58
  • but I seen some apps which are coming with different colors, how they are doing? like makemytrip or other apps – Hanuman Aug 05 '16 at 10:04