Last active
March 1, 2017 09:59
-
-
Save rinav/11172844 to your computer and use it in GitHub Desktop.
Android: Get CountryCode and Locale from TelephonyManager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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