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

相关内容

热门资讯

透视新版"poker... 透视新版"pokerworld辅助器"详细辅助分享教程(辅助神器)1、玩家可以在pokerworld...
透视辅助"拱趴大菠萝... 1、透视辅助"拱趴大菠萝作弊方法"详细辅助曝光教程(辅助真的假的透视)。2、拱趴大菠萝作弊方法透视辅...
透视最新"poker... 1、透视最新"pokerworld破解版下载"详细辅助揭秘攻略(破解器激活码神器);详细教程。2、p...
透视线上"wepok... 1、透视线上"wepoker私人局辅助"详细辅助AI教程(有机器人透明)(UU poker、wepo...
透视好牌"智星德州可... 透视好牌"智星德州可以透视吗"详细辅助可靠技巧(免费钻石技巧)是一款可以让一直输的玩家,快速成为一个...
透视黑科技"wepo... 透视黑科技"wepoker科技辅助器"详细辅助必赢教程(透视脚本免费app教程)是一款可以让一直输的...
透视好友房"wepo... 1、透视好友房"wepoker脚本下载"详细辅助玩家教程(免费脚本技巧);详细教程。2、wepoke...
透视有挂"aapok... 1、透视有挂"aapoker脚本"详细辅助必备教程(安装透视软件神器);详细教程。2、aapoker...
透视线上"wepok... 1、透视线上"wepoker私人局辅助挂"详细辅助黑科技教程(游戏下载软件)2、进入游戏-大厅左侧-...
透视安装"红龙pok... 1、透视安装"红龙poker辅助平台"详细辅助软件教程(手机版透视脚本技巧)。2、红龙poker辅助...