Custom notification sound , android Oreo?

前端 未结 3 587
庸人自扰
庸人自扰 2020-12-09 18:12

I want to set a custom notification sound from a raw mp3 or wav file in my app. Below is my code

private void sendMyNotification(String message) {
    Intent         


        
3条回答
  •  渐次进展
    2020-12-09 18:24

    Late but might be helpful to some one, just add below line in your NotificationCompat.Builder() instance:

    .setSound("your sound uri",AudioManager.STREAM_NOTIFICATION)
    

    Note: As NotificationCompat.Builder() is backward compatible , so AudioAttributes etc in notification channel is not required

提交回复
热议问题