Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity 4.3.0f4 Application.systemLanguage returns Unknown on Android

Discussion in 'Android' started by benni05, Nov 15, 2013.

  1. benni05

    benni05

    Joined:
    Mar 17, 2011
    Posts:
    58
    Hi,

    I really don't want to believe that this is an issue again. :-x But on all of my Android devices I get "Unknown" from Application.systemLanguage. Can anyone confirm this?

    Ben
     
  2. NikolaiS

    NikolaiS

    Joined:
    Dec 28, 2012
    Posts:
    9
    I'm experiencing the same issue on this Unity build.
     
  3. nsejosh

    nsejosh

    Joined:
    Nov 16, 2012
    Posts:
    7
    Yup
     
  4. Nub3h

    Nub3h

    Joined:
    Aug 23, 2012
    Posts:
    56
    Oh so I'm not the only one...yes I can confirm this bug. Did some of you already send a bug report?
     
  5. Aurore

    Aurore

    Director of Real-Time Learning Unity Technologies

    Joined:
    Aug 1, 2012
    Posts:
    3,106
    Anyone reported this as a bug? Could you post the bug number if you have.
     
  6. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    What about iOS?
     
  7. Nub3h

    Nub3h

    Joined:
    Aug 23, 2012
    Posts:
    56
  8. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    When I run a android app created with 4.3 on my Droid 2 it locks up my Droid and I have to take the battery out to start the Droid. I am about to put 4.2 back on. Too many bugs in 4.3.
     
  9. Lotti

    Lotti

    Joined:
    Apr 15, 2013
    Posts:
    18
    same here. f***ed up on andriod
     
  10. Extrawurst

    Extrawurst

    Joined:
    May 22, 2013
    Posts:
    43
    Last edited: Nov 20, 2013
  11. ClockStoneAdmin

    ClockStoneAdmin

    Joined:
    Sep 1, 2012
    Posts:
    56
    I have the same problem on Android. I reported this really severe bug a week ago and my ticket is still open! It seems to happen on ALL Android devices - this bug must effect a whole lot of developers. It's a shame they couldn't make a hotfix yet. This delays our next update, as we have already updated other tools for Unity 4.3 and we don't want to go back to v4.2
     
  12. Jaro

    Jaro

    Joined:
    Jul 26, 2013
    Posts:
    16
    same here...our next update is also delayed! I have only three words for this...WTF
     
  13. SpiriTx

    SpiriTx

    Graphics QA Unity Technologies

    Joined:
    Apr 12, 2012
    Posts:
    252
    Bug has been already fixed, but for now you can workaround the problem by grabbing the language through JNI.

    Code (csharp):
    1. AndroidJavaObject locale = new AndroidJavaClass("java/util/Locale").CallStatic<AndroidJavaObject>("getDefault");
    2. string language = locale.Call<string>("getLanguage");
    3.  
    Issue tracker only includes cases, which were confirmed by QA and converted to bugs, otherwise were would be a lot of sensitive or useless information in there.
     
  14. jfmichel

    jfmichel

    Joined:
    Dec 4, 2013
    Posts:
    2
    This code returns the language code (e.g. "en") and not the language name (e.g. "English") as Application.systemLanguage.ToString() would.
    Here is a more transparent fix :

    Code (csharp):
    1.  
    2. #if UNITY_ANDROID
    3.     // bugfix for Unity 4.3
    4.     AndroidJavaClass localeClass = new AndroidJavaClass("java/util/Locale");
    5.     AndroidJavaObject defaultLocale = localeClass.CallStatic<AndroidJavaObject>("getDefault");
    6.     AndroidJavaObject usLocale = localeClass.GetStatic<AndroidJavaObject>("US");
    7.     string systemLanguage = defaultLocale.Call<string>("getDisplayLanguage", usLocale);
    8. #else
    9.     string systemLanguage = Application.systemLanguage.ToString();
    10. #endif
    11.  
     
  15. Jaro

    Jaro

    Joined:
    Jul 26, 2013
    Posts:
    16
    Unity 4.3.1 was released and I still have the same problem. Language is always Unknown on Android devices. Could someone confirm that ?
     
  16. Extrawurst

    Extrawurst

    Joined:
    May 22, 2013
    Posts:
    43
    yeah, its a joke...
     
  17. jfmichel

    jfmichel

    Joined:
    Dec 4, 2013
    Posts:
    2
    Jaro, I confirm I still have the same problem with Unity 4.3.1. However the fix I posted some days ago is totally transparent. I use it in production code without any problem.
     
  18. dis-s

    dis-s

    Joined:
    Mar 25, 2013
    Posts:
    48
    Hello, thanks for the code!

    Application.systemLanguage returns not String - it returns SystemLanguage.

    To make the code compatible with Application.systemLanguage I have made some changes.

    In fact, I am not completely sure that getDisplayLanguage() result names are completely identical with "SystemLanguage" values... But on my devices with Russian locale this code is working OK.

    Please, confirm this for your devices/languages...

    Code (csharp):
    1.  
    2. static SystemLanguage GetApplicationSystemLanguage() {
    3.     #if UNITY_ANDROID  ! UNITY_EDITOR
    4.         // bugfix for Unity 4.3
    5.         AndroidJavaClass localeClass = new AndroidJavaClass("java/util/Locale");
    6.         AndroidJavaObject defaultLocale = localeClass.CallStatic<AndroidJavaObject>("getDefault");
    7.         AndroidJavaObject usLocale = localeClass.GetStatic<AndroidJavaObject>("US");
    8.         string systemLanguage = defaultLocale.Call<string>("getDisplayLanguage", usLocale);
    9.         SystemLanguage code;
    10.         try {
    11.             code = (SystemLanguage)Enum.Parse(typeof(SystemLanguage), systemLanguage);
    12.         } catch {
    13.             code = SystemLanguage.Unknown;
    14.         }  
    15.     #else
    16.         SystemLanguage code = Application.systemLanguage;
    17.     #endif
    18.     return code;
    19. }
    20.  
     
    Last edited: Dec 7, 2013
  19. MarceloBarce

    MarceloBarce

    Joined:
    Jan 6, 2013
    Posts:
    35
    FINALLY FIXED in Unity 4.3.3
     
  20. naveen_pambi

    naveen_pambi

    Joined:
    Jan 21, 2014
    Posts:
    9