Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defaults from preferences.xml file didn't work for new app installs #12

Open
alankila opened this issue Feb 19, 2011 · 1 comment
Open

Comments

@alankila
Copy link
Contributor

  • Setting a default value for preference in res/xml doesn't work.

I think inserting this call into PlayerActivity's onCreate() will fix it:

PreferenceManager.setDefaultValues(this, R.layout.preferences, false);

The reason the current code didn't work was that the SharedPreferences object is empty initially, because the preferences are in the XML file. This moves them into the SharedPreferences without overwriting user settings (the last "false" in there). I have committed a change to my repository that seems to fix this, and sets VICE as default with "fast (no cycle skipping)" resampling.

  • I also think that registering an onsharedpreferenceschangelistener on the SharedPreferences would be better than registering listeners to the actual preferences in SettingsActivity; an implementation of settings changelistener could just call DroidSoundPlugin.setOptions(prefs).
  • setOption() should be marked static in Java side, because for all plugins the effect seems to be statically implemented. At the limit the native code just stores things in global variables, rather than in some structure that would correspond to the Java-side instance. Therefore marking the method static is semantically more correct. This would allow not constructing plugin instances for DroidSoundPlugin.setOptions().
  • On PlayerActivity's onCreate(), if getLastNonConfigurationInstance() returns something, there is no call to DroidSoundPlugin.setOptions(). This is probably incorrect. Android application lifecycle chart says that the process has been killed and is starting again when onCreate call occurs, therefore natively cached settings must be lost.
@alankila
Copy link
Contributor Author

Correction: res/layout, not res/xml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant