如何将作为String的Preference设置为URI

时间:2016-11-29 08:21:46

标签: android

我试图从首选项中获取URI中的资源mp3文件,并将其设置为Notification to play mp3 Notification sound。但它没有给出错误

obj.setNotificationSound("android.resource://com.packagename.sampleapp/raw/pushsound");

以下是代码: 设置

String setnotificationsound = prefs.getNotificationSound(context);
Uri sound = Uri.parse(setnotificationsound);  //Received String as "R.raw.pushsound" 
            //but getting error (parse (java.lang.string) in URI cannot be applied)
b.setSound(sound);

获得

{{1}}

0 个答案:

没有答案