android - Check if Spell Checker is on? -
i using spell checker in android app. if is off in language , input settings app crashes. needs on app work properly.
is there way before using can place check verify spell checker on or turn on directly code?
you can check instance of spellcheckersession
null
, accordingly decide whether spellchecker
turned on or not:
code snippet:
final textservicesmanager tsm = (textservicesmanager) getsystemservice(context.text_services_manager_service); scs = tsm.newspellcheckersession(null, null, this, true); if (scs != null) { scs.getsuggestions(new textinfo(text.gettext().tostring()), 3); } else { // show message user toast.maketext(this, "please turn on spell checker setting", toast.length_long).show(); // can open settings page user turn on componentname componenttolaunch = new componentname("com.android.settings", "com.android.settings.settings$spellcheckerssettingsactivity"); intent intent = new intent(); intent.addcategory(intent.category_launcher); intent.setcomponent(componenttolaunch); intent.setflags(intent.flag_activity_new_task); try { this.startactivity(intent); } catch (activitynotfoundexception e) { // error } }
hope helps ツ
Comments
Post a Comment