问题
I'm trying to hook into the built in Android spell checking service on my Note tablet. When I call
final TextServicesManager tsm = (TextServicesManager) getSystemService(
Context.TEXT_SERVICES_MANAGER_SERVICE);
spellCheck = tsm.newSpellCheckerSession(null, null, this, true);
spellCheck is always null. The device is 4.1.2, so it ought to at least have the word suggestion capability. Has anyone used this service directly to give me some pointers? The web is very sparse about this, since it usually comes through the keyboard.
回答1:
And I found the answer- Samsung disabled the feature on this model. So I'm either going to have to force users to install 2 APKs and jump some hoops, or include the library as source in my apk.
回答2:
You may want to set the local explicitly, and set last parameter to false, as it checks the active locales on the device.
final TextServicesManager tsm = (TextServicesManager) getSystemService(
Context.TEXT_SERVICES_MANAGER_SERVICE);
spellCheck = tsm.newSpellCheckerSession(null, Local.ENGLISH, this, false);
来源:https://stackoverflow.com/questions/16863274/newspellcheckersession-always-returns-null