2011-10-03 19 views
5

私はあるpreferences.xml好みの着信音のデフォルト値

 <RingtonePreference android:key="ringtone_uri" 
      android:title="@string/preferences_select_ringtone" 
      android:showDefault="true" android:srinlent="true" 
      android:summary="@string/preferences_select_ringtone_summary" /> 

そして、私は着信音の好みをタップすると、私は最初、アプリの:(沈黙のデフォルト値をインストールし、新鮮な起動するたびにこれを持っていますダイアログがデフォルトで選択サイレントで開かれている。私が選択されるデフォルトの「デフォルトの着信音」でほしい。どのように私は、「デフォルトの着信音」サイレントではない、私であることを、デフォルト値を設定することができますどのようにこの enter image description here

を行うことができますなぜ私は自分のコード内の任意の場所に設定されていない私のデフォルトとして静かなのか分からない、サイレントはアンドロイドシステムのデフォルトです...

答えて

5

私は着信音のデフォルト値を設定する方法を探していて、設定が設定されていないときに値が空であり、デフォルトとしてサイレントが選択されていることを認識しました。しかし、私はこれを行う

defaultstr = Uri.parse(PreferenceManager.getDefaultSharedPreferences(context).getString("r_uri", 
    android.provider.Settings.System.DEFAULT_RINGTONE_URI.toString())); 
//than I do this, I save the default ringtone to my setting 
if (defaultstr.equals(android.provider.Settings.System.DEFAULT_RINGTONE_URI)) { 
    PreferenceManager.getDefaultSharedPreferences(context).edit().putString("r_uri", 
     android.provider.Settings.System.DEFAULT_RINGTONE_URI.toString()).commit(); 
} 

私はこれが他の人に役立つことを願っています。ところで、私はこの回避策を見つけること陥る、と私は時間

のための私の頭を糊付けして
1

ただ、「サイレント」の項目を無効:

<RingtonePreference android:key="ringtone_uri" 
      android:title="@string/preferences_select_ringtone" 
      android:showDefault="true" android:srinlent="true" 
      android:summary="@string/preferences_select_ringtone_summary" 
      android:showSilent="false"> 
+0

これはうまくいくかもしれませんが、ユーザーにサイレント着信音を選択させたくない場合に限ります。 – nstCactus

6

着信音に

<RingtonePreference 
     android:showDefault="true" 
     android:showSilent="true" 
     android:defaultValue="content://settings/system/notification_sound" 
        ....... 
     > 
</RingtonePreference> 
をデフォルトにデフォルト値を設定する最も簡単な方法を
関連する問題