I want to show Rs and Doller in my app according to the Country but I don't want to get permission to get User's Current Country.
I will change Rs. sign to Doller if User's Country is not India that will get by User's Mobile Location.
I have tried many things like
String localeCountryCode= this.getResources().getConfiguration().locale.getCountry();
it giving me Result for not what I want
this code gets User's Default set Location in Setting.
But I want real Location Only Country.
How to get Mobiles Current Country Name Or Country Code without any Permission and User's Interaction with android?
- 5 years ago
TelephonyManager telephoneManager = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
String countryCode = telephoneManager.getNetworkCountryIso();
This code will return you your Mobile's Sim Localtion and tell you where are you in country.
It will work in your Scenario.
- 5 years ago
TelephonyManager telephoneManager = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
String countryCode = telephoneManager.getNetworkCountryIso();
This code will return you your Mobile's Sim Localtion and tell you where are you in country.
It will work in your Scenario.
- 5 years ago
You can get Default Selected Country while you setup Your Android Mobile.
String countryCodeValue=""; Locale localCountry = Locale.getDefault(); countryCodeValue=localCountry.getDisplayCountry(); Log.d("TAG", "Country: " + countryCodeValue);
Hot Questions