0

I'm building a soft keyboard, and I can't figure out how to properly build a preferences screen that shows up in the system settings.

I've built the elements screen in xml (preferences.xml), I've populated the options (just a simple ListPreference to select the desired language). That's all fine.

When launching the keyboard (View onCreate InputView()...) I've set things up to write the default preferences to shared preferences:

PreferenceManager.setDefaultValues(getBaseContext(), R.xml.preferences, true);

SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

I've also set up a shared preferences listener to determine whether any changes are made to the preferences so I can update the dictionary:

SharedPreferences.OnSharedPreferenceChangeListener listener = new SharedPreferences.OnSharedPreferenceChangeListener() {
            public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
                // do stuff
            }
        };
SP.registerOnSharedPreferenceChangeListener(listener);

All of this seems to be fine. But I can't for the life of me figure out how to get the preferences screen to show up in the system settings (Settings -> Language and Input -> Keyboard and Input Preferences) so I can actually CHANGE anything. All the other keyboards have a slot here that open up into preference screens where settings can be adjusted. My keyboard name has its own slot, but nothing happens if I touch it. How do I get my preferences screen to be accessible through here?

asetniop
  • 523
  • 1
  • 5
  • 12
  • Okay, turns out the shared preferences listener is NOT fine. It seems to be a case of [this](http://stackoverflow.com/questions/2542938/sharedpreferences-onsharedpreferencechangelistener-not-being-called-consistently) but not sure how to fix that either. – asetniop Mar 01 '17 at 02:44
  • For me the answer here worked worked: http://stackoverflow.com/questions/24839400/how-to-add-preference-activity-to-language-keyboard – netman Mar 25 '17 at 18:20
  • Worked! Can't thank you enough. – asetniop Mar 27 '17 at 01:38

0 Answers0