java问题创建通知兼容任何打开的应用程序

qxsslcnc  于 2021-07-06  发布在  Java
关注(0)|答案(1)|浏览(232)

我有通知兼容它创建新的通知任何打开的应用程序例如,如果打开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());

}
bxgwgixi

bxgwgixi1#

tankyou@eugenpechanec根据文档,如果使用与以前相同的通知id调用notificationmanager.notify,则可以更新通知。只要你的notifac\u id没有改变,它就可以工作了

相关问题