[英]Android Is it possible to get the currency code of the country, where the user and device is?
[英]Not Able to Get Country Where User is Using My Android Application
我无法获得用户正在使用我的Android应用程序的确切国家/地区。 我尝试了多种方式,但未获得确切答案。
首先,我像这样使用TelephonyManager,但没有得到确切答案
TelephonyManager tMgr = (TelephonyManager) CheckCountry.this
.getSystemService(Context.TELEPHONY_SERVICE);
phNo = tMgr.getLine1Number();
然后我用了它,但是它通过从“我的手机设置”中获取返回值
String locale = getApplicationContext().getResources()
.getConfiguration().locale.getCountry();
有AnyOne确切的解决方案,我可以通过该解决方案获取国家名称,然后让我知道
好吧,我为此找到了一个更好的解决方案。 通过使用此api,我可以获得有关用户当前位置和国家/地区的所有详细信息。 这是API
如果连接到美国,则“美国”
TelephonyManager tm = (TelephonyManager)this.getSystemService(this.TELEPHONY_SERVICE);
String countryCodeValue = tm.getNetworkCountryIso();
要么
TelephonyManager tm = (TelephonyManager)this.getSystemService(this.TELEPHONY_SERVICE);
String countryCode = tm.getSimCountryIso();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.