I am trying to set the data source for Anndroid Media Player. I am using the following code.
Uri alarmUri = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_ALARM);
// alarm_uri = null
if (alarmUri == null) {
alarmUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
// alarm_uri = "content://settings/system/notification_sound"
}
alarmMediaPlayer = new MediaPlayer();
alarmMediaPlayer.setDataSource(this, alarmUri);
While setting data source, it throws the following error:
"setDataSource failed.: status=0x80000000"
When I test the same code on another phone, I get the value "content://media/internal/audio/media/44" for alarm_uri. I feel something wrong with the phone which is creating the problem.
Can someone tell what could be the issue?
Both RingtoneManager.TYPE_NOTIFICATION
and RingtoneManager.TYPE_ALARM
were returning invalid value as the URI because alarm and notification were set as none in the device. Once it was set to specific value, it started returning meaningful value.
User contributions licensed under CC BY-SA 3.0