내 알림에 사용하는 사용자 지정 mp3 사운드가 있습니다. API 26 아래의 모든 장치에서 정상적으로 작동합니다. 알림 채널에서도 사운드를 설정하려고했지만 여전히 작동하지 않습니다. 기본 사운드를 재생합니다.알림 소리가 API 26
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelId)
.setAutoCancel(true)
.setSmallIcon(R.drawable.icon_push)
.setColor(ContextCompat.getColor(this, R.color.green))
.setContentTitle(title)
.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notification))
.setDefaults(Notification.DEFAULT_VIBRATE)
.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setContentText(message);
Notification notification = builder.build();
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT);
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
.build();
channel.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notification), audioAttributes);
notificationManager.createNotificationChannel(channel);
}
notificationManager.notify(1, notification);
기본 알림 음을 음소거 했습니까? 나는 또한 동일한 문제에 직면하고있다. NotificationManager.IMPORTANCE_MAX를 사용하여 통보 할 때 어떤 소리도 내고 싶지 않습니다. 이걸 좀 도와주세요. –