I'm adding sound to certain notifications in my app, like so:
Notification notification = ...
...
notification.sound = Uri.parse(...);
When the notification sound plays it does so through the speakers even when headphones are plugged to the phone, and so the sound is played in both the speakers and headphones.
Is there a way to play the sound only through the headphones if it's plugged in?