【问题标题】:NotificationCompat.PRIORITY_DEFAULT doesn't make sound on older OS versionsNotificationCompat.PRIORITY_DEFAULT 在较旧的操作系统版本上没有声音
【发布时间】:2019-06-02 01:49:11
【问题描述】:

我没有指定任何声音(资源),我想使用默认声音

在 Android 8 和 9 上运行良好

但在 Android 4-7 上它会触发无声通知

如何在所有 Android 设备上实现相同的行为?

通知生成器:

NotificationCompat.Builder(this, channelId)
    .setSmallIcon(R.drawable.notify_icon
    .setContentTitle(title)
    .setContentText(subtitle)
    .setPriority(if (Prefs.isNotificationSound) NotificationCompat.PRIORITY_DEFAULT else NotificationCompat.PRIORITY_LOW)
    .setCategory(NotificationCompat.CATEGORY_PROMO)
    .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
    .setAutoCancel(true)

【问题讨论】:

    标签: android android-notifications


    【解决方案1】:

    你试过用.setDefaults(Notification.DEFAULT_SOUND)吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-24
      相关资源
      最近更新 更多