I want set Notification ring ,this is my code :
Notification notification = new Notification();
String ringName = RingtoneManager.getActualDefaultRingtoneUri(
MainActivity.this, RingtoneManager.TYPE_NOTIFICATION).toString();
notification.sound = Uri.parse(ringName);
but i find that .toString() will led app crash in emulater.
"RingtoneManager.getActualDefaultRingtoneUri( MainActivity.this, RingtoneManager.TYPE_NOTIFICATION)" return NULL ,because emulater set notification ring is silent.
So i guest that if URI is NULL , we can's use Uri.toString() to convert URI to String ?
yes, i make a test to prove my guess . Because this android emulator set ringtone , notification ,alarm to be silent and there is no music file in emulator.
so first i use
abd to push 1.mp3 to sdcard/notification/
then go to
"dev tool -->media provider-->scan sdcard --> insert abulm . and go to android --> system setting-->sound-->set notification to 1.mp3"
and run my code again , there is no problem come out.
So, if URI is NULL , we can't use Uri.toString() to convert uri to string, this will get a nullpoint error.
But why ? i hope someone that could give a detail explain ! thanks