android - Detect installed languages for offline recognition -


it possible determine via code language packages installed on device? tried this:

    intent detailsintent =  new intent(recognizerintent.action_get_language_details);     sendorderedbroadcast(detailsintent, null, new languagedetailschecker(), null, activity.result_ok, null, null); 

 

    public class languagedetailschecker extends broadcastreceiver  {      private list<string> supportedlanguages;      @override     public void onreceive(context context, intent intent)     {         bundle results = getresultextras(true);         if (results.containskey(recognizerintent.extra_supported_languages))         {             supportedlanguages =results.getstringarraylist(recognizerintent.extra_supported_languages);             log.d("tag","languages: " + supportedlanguages);         }     } } 

however, output shows me tons of languages, while have en_uk, en_us , es_es installed. idea?

if have root(sorry), can way:

public static boolean isofflinedictionarypresent(string language) {     if (locale == null) locale = locale.us;     string dir = "/system/usr/srec/config/" +             language.replace('_', '.').tolowercase();     if ((new file(dir)).isdirectory()) return true;     return false; } 

this ripped android 4.2.2 recognizer.java source , modified:

  • returns simple boolean instead of dictionary directory
  • takes string input(ex. "en_us") instead of locale

i'd full list are, , loop through them check ones available offline. i've checked /system/usr/srec/config/ folder on 2 devices, , both match dictionaries have installed.

of course, down side works root, i'm not sure how helpful in end. i'm not sure non-root, can't find anything.


edit: out of curiosity, though, extra_supported_languages contain if are offline? if returns correctly, might have fake out network manager.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -