NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setContentTitle(context.getString(R.string.alarm))
.setContentText(intent.getStringExtra("alarm_title"))
.setSmallIcon(R.drawable.bell_outline_symbolic)
.setSound(customSoundUri)
.setAutoCancel(true);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
< /code>
i, за исключением того, что он воспроизводит звук из URI, но он воспроизводит звук уведомления по умолчанию (устанавливается настройками устройства). URI находится в библиотеке звуков устройства (например: Content: // Media/Internal/Audio/Media/13? Title = Tweetters & Canonical = 1
), и он хорошо работает с MediaPlayer, но не с уведомлениями.>
В своем проекте я пытаюсь использовать пользовательский звук в уведомлениях.[code]NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID) .setContentTitle(context.getString(R.string.alarm)) .setContentText(intent.getStringExtra("alarm_title")) .setSmallIcon(R.drawable.bell_outline_symbolic) .setSound(customSoundUri) .setAutoCancel(true);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build()); < /code> i, за исключением того, что он воспроизводит звук из URI, но он воспроизводит звук уведомления по умолчанию (устанавливается настройками устройства). URI находится в библиотеке звуков устройства (например: Content: // Media/Internal/Audio/Media/13? Title = Tweetters & Canonical = 1 [/code]), и он хорошо работает с MediaPlayer, но не с уведомлениями.>