我有下面的代码。执行代码时,将显示通知,但不会显示远程视图。
我的意思是我在notifaction中看不到R.layout.layout update_bar。

mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotification = new Notification(R.drawable.close_icon,"Pet Parrot", System.currentTimeMillis());
mNotification.defaults = 4;

mRemoteView = new RemoteViews(getPackageName(), R.layout.layout_update_bar);
mNotification.contentView = mRemoteView;
mNotification.contentView.setProgressBar(R.id.progress,100,44,false);
mNotification.contentView.setTextViewText(R.id.title, "Siddharth" + "2km -> 20km");
//mNotification.flags |= Notification.FLAG_AUTO_CANCEL;
CharSequence contentTitle = "download";
Intent notificationIntent = new Intent(this,PhotoSaSa.class);
PendingIntent contentIntent = PendingIntent
    .getActivity(this, 0, notificationIntent, 0);
mNotification.setLatestEventInfo(this, contentTitle,"", contentIntent);

mNotifyManager.notify(1, mNotification);

最佳答案

调用setLatestEventInfo()会覆盖您的自定义contentView。将其移动到第3行,或者更好的是,切换到Notification.Builder api。

10-07 18:12