4

I'm using a remote view for custom notification layout. Everything works fine. Only problem that I'm facing is the notification is displayed as a white circle in the notification status bar. I want my app icon to be shown in the notification status bar(how it shows in kitkat & lower versions). is there any way to change this?

private void showNotification() {

        Intent intent = new Intent(this, HomeActivity.class);
        intent.putExtra(LIVE_RADIO_PUSH, true);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 1, intent, 0);
        mBuilder = new NotificationCompat.Builder(this);
        mBuilder.setCategory(Notification.CATEGORY_SERVICE);
        mBuilder.setContentTitle(mTitle);
        mBuilder.setContentText("Live Radio");
        mBuilder.setSmallIcon(R.drawable.logo);
        mBuilder.setWhen(System.currentTimeMillis());
        mBuilder.setVisibility(Notification.VISIBILITY_PUBLIC);
        mBuilder.setContentIntent(pendingIntent);
        mBuilder.setColor(getResources().getColor(R.color.theme_primary));
        mNotificationView = new RemoteViews(getPackageName(), R.layout.notification_layout);
        mNotificationView.setTextViewText(R.id.content_title, mTitle);
        mNotificationView.setTextViewText(R.id.content_text, "Live Radio");
        SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm");
        String time = dateFormat.format(new Date(System.currentTimeMillis()));
        mNotificationView.setTextViewText(R.id.current_time, time);
        mNotificationView.setImageViewResource(R.id.play_pause, R.drawable.pause_radio);
        mNotificationView.setImageViewResource(R.id.close_btn, R.drawable.notifictn_close_btn);


        setListeners(mNotificationView);
        mBuilder.setContent(mNotificationView);
        Log.d(TAG, "App is freezed2");
        if (null != mNotificationMngr)
            mNotificationMngr.notify(RADIO_NOTIFICATION_ID, mBuilder.build());
    }
Sangeetha Pinto
  • 1,022
  • 3
  • 14
  • 32

3 Answers3

2

I have encountered this issue too, as you mention, if your ANDROID_BUILD_TARGET_SDK_VERSION = 21, it will change this notification into white.

The notification icon design guideline as this link. http://developer.android.com/design/style/iconography.html

Porco
  • 46
  • 2
  • I have the minSdkVersion set to 8 and the targetSdkVersion set to 17 and still experience this same problem on devices running Android 6.0. Has anyone else experienced such behaviour ? – Sandra Aug 19 '16 at 09:23
0

Recently we done one application with notification.Its working fine in lollipop also.Once check the below code may be it will helps you.

mNotification = new Notification.Builder(this).setContentTitle("M3 Media Player").setContentIntent(mPendingIntentHome)
                    .setSmallIcon(R.drawable.app_icon).setPriority(Notification.PRIORITY_MAX).setContent(mNotificationContentView)
                    .setStyle(new Notification.BigPictureStyle()).build();
Ramesh
  • 526
  • 3
  • 14
  • My notifications are working properly. only problem is in the status bar it is displayed as white. But When I open the notification area, it shows properly. My question is how can I change that white color to my notification icon? – Sangeetha Pinto Feb 13 '15 at 04:08
  • Also, I have refered this link: http://stackoverflow.com/questions/28387602/notification-bar-icon-turns-white-in-android-5-lollipop where they are saying, its because the design is changed in lollypop. // statusbar/BaseStatusBar.java if (entry.targetSdk >= Build.VERSION_CODES.LOLLIPOP) { entry.icon.setColorFilter(mContext.getResources().getColor(android.R.color.white)); } else { entry.icon.setColorFilter(null); } – Sangeetha Pinto Feb 13 '15 at 04:08
0

If your compileSDKversion is above 20 then notification icon should be a white-on-transparent background image. Otherwise the image will be rendered as a white colored image.

Please go through the below link too for guidelines to create the icon

https://www.google.com/design/spec/patterns/notifications.html

and also the notification icon generator.

https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.space.trim=1&source.space.pad=0&name=ic_stat_example

Jiju Induchoodan
  • 4,236
  • 1
  • 22
  • 24
  • But most of the App icons still today are colorful. how is it possible? I dont thinkg that they compile with old SDK, do they? – Emil May 21 '17 at 15:18