gpt4 book ai didi

java - android通知remoteview不显示

转载 作者:行者123 更新时间:2023-12-01 04:17:10 28 4
gpt4 key购买 nike

我的代码如下。当代码执行时,会显示通知,但不会显示远程 View 。

我的意思是我在通知中看不到 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。

关于java - android通知remoteview不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19332769/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com