Question

i ont une préférence de sonnerie. Comment puis-je obtenir la sélection? J'ai le genre-de-code suivant:

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();
            }
Était-ce utile?

La solution

Voici comment vous attribuez la sélection à votre instance de notification.

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

Lorsque la notification est:

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

Vous trouverez plus d'informations ici: http://developer.android.com /reference/android/app/Notification.html

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top