Ringtone Preference not saving choice

前端 未结 6 427
梦如初夏
梦如初夏 2021-01-13 13:40

I have a ringtone preference in my app but when I select the tone I want, it does not get stored in the preference value. I can click the preference again and it will not sh

相关标签:
6条回答
  • 2021-01-13 14:12

    I ended up saving it manually by registering a onPreferenceClickListener and getting the result

    0 讨论(0)
  • 2021-01-13 14:14

    If you have overriden onActivityResult() and forgotten to call super.onActivityResult() you can see this problem as well.

    See RingtonePreference not firing OnPreferenceChangeListener

    0 讨论(0)
  • 2021-01-13 14:14

    I managed to resolve this by removing android:launchMode="singleInstance" and android:excludeFromRecents="true" from the settings activity entry on AndroidManifest.xml (setting either or both of these options will cause the same issue). It seems to be a bug on Android.

    0 讨论(0)
  • 2021-01-13 14:16

    the solution I used was provided by Udo Held, I just wanted to add one thing, I had to remove the launchMode="singleInstance" and I am now using android:launchMode="singleTask" and everything works fine. Just in case someone else needs a launchMode, this one worked for me.

    0 讨论(0)
  • 2021-01-13 14:25

    I just had the same problem, but then I reviewed my codes, when I read the preference:

    SharedPreferences settings = 
    context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE);
    

    Which is wrong, the correct solution is:

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    

    Hope it helps

    0 讨论(0)
  • 2021-01-13 14:30

    I had the same problem. In the AndroidManifest.xml file I had my preference activity set with noHistory="true". Once I removed it everything worked correctly.

    0 讨论(0)
提交回复
热议问题