Skip to content

Instantly share code, notes, and snippets.

@rinav
Last active March 1, 2017 09:59
Show Gist options
  • Select an option

  • Save rinav/11172844 to your computer and use it in GitHub Desktop.

Select an option

Save rinav/11172844 to your computer and use it in GitHub Desktop.
Android: Get CountryCode and Locale from TelephonyManager
// get current location iso code
TelephonyManager telMgr = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
String curLocale = telMgr.getNetworkCountryIso().toUpperCase();
Log.d(Constants.LOG_TAG, "CurrLocale: " + curLocale);
//gets the international dialling code for our current location
String curDCode = String.format("%d", phoneUtil.getCountryCodeForRegion(curLocale));
Log.d(Constants.LOG_TAG, "curDCode: " + curDCode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment