【发布时间】:2020-11-14 07:48:28
【问题描述】:
我有 NotificationCompat 粘性 它会在任何打开的应用程序中创建新通知 例如,如果打开 10 次应用程序创建 10 个通知 请帮帮我
public void Notifa(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
String offerChanelsName ="Shop Now Offers";
String offerDescription ="Description Offer Names ";
int offerChaqnelImportan = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel notificationChannel =new NotificationChannel(offerChannelId,offerChanelsName,offerChaqnelImportan);
notificationChannel.setDescription(offerDescription);
notificationManager.createNotificationChannel(notificationChannel);
}
builder = new NotificationCompat.Builder(context,offerChannelId);
builder.setSmallIcon(R.mipmap.ic_launcher)
.setAutoCancel(false)
.setCustomBigContentView(remoteViews)
.setOngoing(true)
.setContentIntent(pending);
notificationManager.notify(notifac_id,builder.build());
}
【问题讨论】:
-
根据documentation,如果您使用与以前相同的通知ID 调用
NotificationManager.notify,则可以更新通知。只要您的notifac_id没有改变,它就应该可以工作。
标签: java android notifications android-notifications