Help in a simple (or not) aplication

Last Updated:

  1. IGSG

    IGSG New Member

    Hey everyone!
    It's nice to be a new member in this community!

    I'm beginner at android development and i start development an application and i need your help, please.
    What i want to do is an app that just shows one button, at the end of the button, it should appear a country flag, this country flag must be the flag of the country language of the phone. By clicking in the button. it will open a website in the default mobile language(correspondig to the flag). If we want to open the website in other language, we should click beside the country flag an it will appears other country flags that we can click.
    The code to open the website is ok, my biggest dificults are to know the default language of the phone and in function of this, put the flag after the button and make the menu beside the flag in case we want open site in other language. How i would make the mail.xml contains the squeme is other problem.


    If someone could help me, i will be very grateful.

  2. markb

    markb Well-Known Member

    The java.util.Locale class might be of use to you.

    Locale | Android Developers)

    Code (Text):
    2. Locale locale = Locale.getDefault() ;
    4. Log.d(TAG, "Locale getCountry = "+locale.getCountry()) ;
    5. Log.d(TAG, "Locale getDisplayCountry = "+locale.getDisplayCountry()) ;
    6. Log.d(TAG, "Locale getISO3Country = "+locale.getISO3Country()) ;
    7. Log.d(TAG, "Locale getLanguage = "+locale.getLanguage()) ;
    8. Log.d(TAG, "Locale getgetDisplayLanguage = "+locale.getDisplayLanguage()) ;
    I get the following results, which are correct for me:

    Code (Text):
    2. Locale getCountry = GB
    3. Locale getDisplayCountry = United Kingdom
    4. Locale getISO3Country = GBR
    5. Locale getLanguage = en
    6. Locale getgetDisplayLanguage = English

Share This Page