Question

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();
            }
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top