newSpellCheckerSession always returns null

醉酒当歌 提交于 2019-12-01 15:12:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!