java - 问题创建 NotificationCompat 任何打开的应用程序
问题描述
我有 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());
}
解决方案
Tankyou @EugenPechanec 根据文档,如果您使用与以前相同的通知 ID 调用 NotificationManager.notify,则可以更新通知。只要你的 notifac_id 没有改变,它应该可以工作。——</p>
推荐阅读
- php - 如何从 php 获取数据以添加 vue 的 json 数据?
- intellij-idea - 如何在 IntelIj Idea 中打开带有视图的底部工具窗口?
- docker - Dockerfile RUN mkdir 不创建文件
- error-handling - 从观察者内部的“下一个”函数调用“错误”
- python-3.x - 通过 REST API 创建 Keycloak 客户端
- symfony - 拥有一个在教义中使用 ID 实体的 CustomIdGenerator 是个好主意吗?
- angular - Datepicker - 以毫秒为单位的日期 - 生日检查
- c++ - 为什么 MSVC 从堆栈中推送和弹出与 Clang 不同
- python - 在 PyQt GUI 中集成 QPainter
- python - Selenium 中的单例实现 [Python]