【问题标题】:Problem create NotificationCompat any open app问题创建 NotificationCompat 任何打开的应用程序
【发布时间】: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


【解决方案1】:

坦克友@EugenPechanec 根据文档,如果您使用与以前相同的通知 ID 调用 NotificationManager.notify,则可以更新通知。只要你的 notifac_id 没有改变,它应该可以工作。 ——

【讨论】:

    猜你喜欢
    • 2021-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多