Android13中通知不显示下一页和上一页按钮
创始人
2024-10-01 11:30:16
0

在Android 13中,通知的下一页和上一页按钮已被隐藏。要显示这些按钮,需要添加以下代码:

if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.S){
      Notification.BubbleMetadata bubbleMetadata = null;
      Notification.Builder builder = new Notification.Builder(context, channelId)
                  .setContentTitle(title)
                  .setContentText(content)
                  .setSmallIcon(R.drawable.ic_launcher_foreground)
                  .setBubbleMetadata(bubbleMetadata);

      Notification.Action prevAction = new Notification.Action.Builder(
          Icon.createWithResource(context, R.drawable.ic_previous),
          "Previous",
          prevPendingIntent
      ).build();

      Notification.Action nextAction = new Notification.Action.Builder(
          Icon.createWithResource(context, R.drawable.ic_next),
          "Next",
          nextPendingIntent
      ).build();

      builder.addAction(prevAction);
      builder.addAction(nextAction);

      notificationManager.notify(notificationId, builder.build());
  }
  else {
      NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId)
                  .setContentTitle(title)
                  .setContentText(content)
                  .setSmallIcon(R.drawable.ic_launcher_foreground);

      NotificationCompat.Action prevAction = new NotificationCompat.Action.Builder(
          R.drawable.ic_previous,
          "Previous",
          prevPendingIntent
      ).build();

      NotificationCompat.Action nextAction = new NotificationCompat.Action.Builder(
          R.drawable.ic_next,
          "Next",
          nextPendingIntent
      ).build();

      builder.addAction(prevAction);
      builder.addAction(nextAction);

      notificationManager.notify(notificationId, builder.build());
  }

上面的代码进行了检查,如果设备API级别为Android 13或更高级别,则使用Notification.BubbleMetadataNotification.Action.Builder添加下一页和上一页按钮。否则,使用NotificationCompat.Action.Builder添加按钮。

值得注意的是,添加下一页和上一页按钮将使通知显示为气泡。如果您不想要气泡,可以将Notification.BubbleMetadatasetBubbleMetadata()删除,并将builder替换为NotificationCompat.Builder

相关内容

热门资讯

十分钟开挂!科乐填大坑破解版安... 十分钟开挂!科乐填大坑破解版安卓,潮汕掌上辅助挂定制交易平台(终于知道开挂辅助工具);亲,科乐填大坑...
一分钟辅助!决战卡五星辅助修改... 一分钟辅助!决战卡五星辅助修改器,广东雀神祈福有用吗(1.9分钟了解开挂辅助工具);人气非常高,ai...
第9分钟开挂!九九山城万州辅助... 大家好,今天小编来为大家解答九九山城万州辅助这个问题咨询软件客服可以免费测试直接加微信(136704...
3分钟辅助!情怀辅助哪里可以装... 3分钟辅助!情怀辅助哪里可以装,哈糖大菠萝提高胜率(教程攻略开挂辅助下载),情怀辅助哪里可以装是用手...
第三分钟透视!手机暗宝辅助,哈... 第三分钟透视!手机暗宝辅助,哈糖大菠萝辅助(玩家必看科普开挂辅助软件) 了解更多开挂安装加(1367...
第8分钟辅助!wepoker底... 第8分钟辅助!wepoker底牌透视脚本,天天开心国王辅助(1.9分钟了解开挂辅助软件);致您一封信...
第1分钟开挂!蜀山挂件辅助,填... 第1分钟开挂!蜀山挂件辅助,填大坑辅助视频(透视辅助开挂辅助脚本);亲,填大坑辅助视频这款游戏原来确...
第4分钟辅助!wepoker辅... 《第4分钟辅助!wepoker辅助是真的假的,小程序微乐辅助器2.0(透视辅助开挂辅助下载)》 小程...
第二分钟透视!四川家园茶馆辅助... 【亲,四川家园茶馆辅助 这款游戏可以开挂的,确实是有挂的,很多玩家在这款四川家园茶馆辅助中打牌都会发...
9分钟辅助!金州水鱼天下源码,... 9分钟辅助!金州水鱼天下源码,微玩盒子网页游戏辅助(透视辅助开挂辅助安装);微玩盒子网页游戏辅助最新...