开发者

Android ringtone preference - fetch data

i have a ringtone preference. How can i get the selection? I have the following kind-of-code:

if(preferences.getString("ringtonePref", "n/a") != ??)
            {
                Toast.makeText(TutorialPref.this,   "Chosen ringtone: silent", To开发者_如何学编程ast.LENGTH_LONG).show();
            }
            else if(preferences.getString("ringtonePref", "n/a") != "DEFAULT_RINGTONE_URI" )
            {
                Toast.makeText(TutorialPref.this,   "Chosen ringtone: + default", Toast.LENGTH_LONG).show();
            }


This is how you assign the selection to your notification instance.

String strRingtonePreference = preferences.getString("ringtonePref", "DEFAULT_RINGTONE_URI");
notification.sound = Uri.parse(strRingtonePreference);

Where notification is :

Notification notification = new Notification(icon, tickerText, time);

You will find more info here : http://developer.android.com/reference/android/app/Notification.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜