Reputation: 1022
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());
}
Upvotes: 4
Views: 11001
Reputation: 4266
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.
Upvotes: 0
Reputation: 44
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
Upvotes: 2
Reputation: 526
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();
Upvotes: 0