Obsolete
Status Update
Comments
th...@gmail.com <th...@gmail.com> #2
I'm experiencing the same thing. The code below shows an empty notification; the equivalent with new Notification() works. Frankly, I am confused about the purpose of the notification builder, which just seems like a more complicated way to do something simple. I was trying it to see if it would help me get around another bug where the pendingIntent from contentView.setOnClickPendingIntent doesn't fire on certain versions of Android. Oh well.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentIntent(contentIntent);
builder.setSmallIcon(icon);
builder.setTicker(tickerText);
builder.setWhen(when);
builder.setOngoing(true);
builder.setContent(contentView);
notification = builder.getNotification();
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentIntent(contentIntent);
builder.setSmallIcon(icon);
builder.setTicker(tickerText);
builder.setWhen(when);
builder.setOngoing(true);
builder.setContent(contentView);
notification = builder.getNotification();
[Deleted User] <[Deleted User]> #3
I am having the same issue. I am using the latest support library v4 on emulator v2.1.
br...@gmail.com <br...@gmail.com> #4
The following code in NotificationCompat.NotificationCompatImplBase.getNotification() causes this issue.
Notification result = (Notification) b.mNotification;
result.setLatestEventInfo(b.mContext, b.mContentTitle, b.mContentText, b.mContentIntent);
Notification result = (Notification) b.mNotification;
result.setLatestEventInfo(b.mContext, b.mContentTitle, b.mContentText, b.mContentIntent);
ds...@android.com <ds...@android.com>
vo...@gmail.com <vo...@gmail.com> #5
I experience the same issue: RemoteViews not working with NotificationCompat
az...@gmail.com <az...@gmail.com> #6
Try to do such workaround:
.....
notification = builder.build();
notification.contentView = contentView;
.....
notification = builder.build();
notification.contentView = contentView;
wa...@gmail.com <wa...@gmail.com> #7
[Comment deleted]
ee...@gmail.com <ee...@gmail.com> #8
The workaround in comment #6 works. This way the RemoteViews show up correctly.
Hoever, the click listeners that were set on views inside the RemoteViews (via setOnClickPendingIntent), still don't get called.
Hoever, the click listeners that were set on views inside the RemoteViews (via setOnClickPendingIntent), still don't get called.
[Deleted User] <[Deleted User]> #9
I am experiencing the same issue and I have tried something like this with the workaround on #6 .. maybe I'm doing something wrong?
private void sendNotification(String msg,String ticker) {
mNotificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, SplashActivity.class), 0);
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
contentView.setTextViewText(R.id.notification_text,msg);
contentView.setTextViewText(R.id.notification_title,msg);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setContentIntent(contentIntent);
Notification notification = mBuilder.build();
notification.contentView = contentView;
mNotificationManager.notify(NOTIFICATION_ID, notification);
}
private void sendNotification(String msg,String ticker) {
mNotificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, SplashActivity.class), 0);
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
contentView.setTextViewText(R.id.notification_text,msg);
contentView.setTextViewText(R.id.notification_title,msg);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setContentIntent(contentIntent);
Notification notification = mBuilder.build();
notification.contentView = contentView;
mNotificationManager.notify(NOTIFICATION_ID, notification);
}
ch...@beyls.net <ch...@beyls.net> #10
This bug is caused by the pre-honeycomb implementation calling setLatestEventInfo() during build(). This method creates and sets a new contentView overriding the current one, at least in Gingerbread.
Google should fix the pre-honeycomb implementation in the support library.
Google should fix the pre-honeycomb implementation in the support library.
vo...@gmail.com <vo...@gmail.com> #11
I'm seeing this behavior on Nougat/24 with the latest support-v13 library (24.2.0 at the time of writing).
This was a recent regression in the support library, I BELIEVE when I went to 24.0.0.
Workaround in #6 helped.
This was a recent regression in the support library, I BELIEVE when I went to 24.0.0.
Workaround in #6 helped.
sa...@google.com <sa...@google.com> #12
Thank you for your feedback. We assure you that we are doing our best to address the issue reported, however our product team has shifted work priority that doesn't include this issue. For now, we will be closing the issue as won't fix obsolete. If this issue currently still exists, we request that you log a new issue along with latest bug report here https://goo.gl/TbMiIO .
Description
- Steps to reproduce the problem.
NotificationCompat.Builder builder = new Builder(context);
builder.setAutoCancel(true);
builder.setSmallIcon(R.drawable.notification_icon);
builder.setContentIntent(pendingIntent);
builder.setTicker(tickerText);
RemoteViews iconView = new RemoteViews(context.getPackageName(), R.layout.custom_notification);
if (icon != null) {
iconView.setImageViewBitmap(R.id.custom_notification_image, icon);
}
iconView.setTextViewText(R.id.custom_notification_title, title);
iconView.setTextViewText(R.id.custom_notification_text, content);
builder.setContent(iconView);
...
- What happened.
A notification with the default content view was created
- What you think the correct behavior should be.
A notification with with the custom layout I supplied should be created