7

Here is my code snippet to play ringtone notification:

Uri u = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(MainActivity.this, u);
r.play();

This seems to work fine on most devices. However, on some devices such as Samsung S8 and Samsung S9, it does not work. Logcat shows:

I/Ringtone: Internal uri : content://settings/system/notification_sound
D/RingtoneManager: getActualDefaultRingtoneUri  type    :2
W/MediaPlayer: Couldn't open content://0@settings/system/notification_sound_cache: 
java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)

Note that the same code works fine on Samsung S7.

Wondering if anyone has any insight.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Peter
  • 11,260
  • 14
  • 78
  • 155
  • check this link https://stackoverflow.com/questions/2618182/how-to-play-ringtone-alarm-sound-in-android – unzila Sep 28 '18 at 10:24

0 Answers0