알림을 작성할 때 setSound(uri)
을 사용하여 소리에 알림을 설정할 수 있습니다.
public NotificationCompat.Builder setSound (Uri sound)
Set the sound to play. It will play on the default stream.
또는 setDefaults(Notification.DEFAULT_SOUND)
을 기본 사운드 재생에 사용할 수 있습니다. 예를 들어
:
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setDefaults(Notification.DEFAULT_SOUND)
.setTicker (text)
.setSmallIcon(R.drawable.icon)
.setContentText (text)
.setContentTitle(title)
.setStyle(new NotificationCompat.BigTextStyle().bigText(text))
.setAutoCancel(true).setNumber (4)
.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
지금까지 내가 아는 한, 통지가 표시 될 때 (내가 확인하지 않은 있지만)이 사운드가 재생됩니다. 그러나 그렇지 않은 경우
mNotificationManager.notify
에 전화하기 전에 알림 (방송 수신기 또는 의도 서비스에서)을 나타내는 코드의 알림과 상관없이 사운드를 재생할 수 있습니다.