How to play sound when a notification pops up?
问题 I'm working on an app where using two switch buttons the user can turn on/off notifications and notification sound. I created the notifications that pop up on the status bar and I want to play a default sound when they appear.I wrote the following code but it doesn't seem to work. Any ideas about how can I make the notification sound play ? import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Notification; import android.app.NotificationChannel;