2011-01-21 3 views
2

나는 벨소리 환경 설정을 가지고 있습니다. 선택을 어떻게받을 수 있습니까? 다음과 같은 종류의 코드가 있습니다.Android 벨소리 환경 설정 - 데이터 가져 오기

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(); 
      } 

답변

5

알림 인스턴스에 선택 항목을 지정하는 방법입니다. http://developer.android.com/reference/android/app/Notification.html

+0

' "DEFAULT_RINGTONE_URI"'작동하지 않습니다 당신은 여기에 더 많은 정보를 찾을 수

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

: 통지가

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

. 'SharedPreferences.getString'가'null'을 반환하면'Uri.parse' 대신'RingtoneManager.getActualDefaultRingtoneUri'를 호출하십시오. –

+0

기본 설정이 null을 반환 할 때'Settings.System.DEFAULT_NOTIFICATION_URI'도 좋은 기본값입니다. – Jeshurun