Search code examples
androidtelephonymanager

How to get Mobile Country Code like +91 for India?


I had tried using TelephonyManager

TelephonyManager telephonyManager=(TelephonyManager)getBaseContext().
    getSystemService(Context.TELEPHONY_SERVICE);
String CountryIso= telephonyManager.getNetworkCountryIso();
String NetworkIso=telephonyManager.getSimCountryIso();

Solution

  • There are always huge discussions about this, and I never understand why developers and companies go for the complex way. The language selected by the user, means the language he/she wants to see always in his/her phone. They don't intend to have apps in a different language than others or the system.

    The choice is very straight forward: Use Locale (to get the language the user selected as preferred), or make your best to piss them off showing them information in a language they already said they don't want to see things in.

    To get the country code use:

    Locale.getDefault().getCountry();