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

Popular posts from this blog

javascript - IndexedDB error: Uncaught DataCloneError: Failed to execute 'put' on 'IDBObjectStore': An object could not be cloned -

amazon web services - When using Cognito credentials with AWS in a browser (javascript), keep getting "missing credentials" error -

c# - How to set the datatextfield value instead of the value on a drop down list? -