开发者

Android ringtone preference - fetch data

开发者 https://www.devze.com 2023-02-06 04:58 出处:网络
i have a ringtone preference. How can i get the selection? I have the following kind-of-code: if(preferences.getString(\"ringtonePref\", \"n/a\") != ??)

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

精彩评论

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