Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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", Toast.LENGTH_LONG).show();
            }
            else if(preferences.getString("ringtonePref", "n/a") != "DEFAULT_RINGTONE_URI" )
            {
                Toast.makeText(TutorialPref.this,   "Chosen ringtone: + default", Toast.LENGTH_LONG).show();
            }
like image 846
erdomester Avatar asked Jun 12 '26 21:06

erdomester


1 Answers

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

like image 82
Radu Avatar answered Jun 16 '26 11:06

Radu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!