【问题标题】:Changing sound and vibration for Notification Channel on Oreo 8.1在 Oreo 8.1 上更改通知通道的声音和振动
【发布时间】:2018-11-28 05:43:50
【问题描述】:

通知通道的正式声音和振动是 "只能在频道提交前修改 NotificationManager.createNotificationChannel(NotificationChannel)。”

但我现在看到,当转到 Whatsapp 设置并更改声音或振动时,这些更改会出现在相应频道(私人或群组)的设置中。

我该怎么做? (我使用的是安卓 8.1)

【问题讨论】:

    标签: android


    【解决方案1】:

    Whatsapp 不会编辑频道,只要您进行任何更改,他们就会删除频道并创建一个具有相同名称(具有不同 ID)的新频道。我现在发现,每次您进行更改时,“已删除类别”的数量都会增加。

    【讨论】:

      【解决方案2】:

      您可以通过在 notificationChannel

      中添加声音和振动来做到这一点

      例如:

          Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
          String notifyID = "1003";
          String CHANNEL_ID = "my_channel_01";// The id of the channel.
          NotificationChannel notificationChannel = null;
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
              int importance = NotificationManager.IMPORTANCE_HIGH;
              notificationChannel = new NotificationChannel(notifyID, CHANNEL_ID, importance);
              notificationChannel.enableLights(true);
              notificationChannel.setSound(defaultSoundUri, null);
              notificationChannel.setLightColor(Color.RED);
              notificationChannel.enableVibration(true);
              notificationChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
          }
      

      【讨论】:

      • 这没有回答问题
      • 你试过了吗???使用此创建通知并转到您的应用设置>通知,您可以在其中获得诸如 Whatsapp 之类的选项
      • 转到whatsapp并打开那里的设置,这就是问题所在,而不是如何创建频道。
      猜你喜欢
      • 1970-01-01
      • 2017-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多