如何获得国家(或其ISO代码)? [英] How can I get the country (or its ISO code)?
问题描述
获取国家/地区代码的最佳方法是什么?
What is the best way to get the country code?
到目前为止,我知道两种方法.一种是通过TelephonyManager获得,另一种是通过语言环境获得.在Android上查找国家/地区代码的另一种最佳且独特的方法是
As of now, I know two ways. One is to get by TelephonyManager and another by Locale. Which is another best and unique way to find the country code on Android?
推荐答案
我通过IP地址解决了它.您可以获取手机的IP地址.如果您使用的是Wi-Fi,则它将是Wi-Fi的IP地址热点或移动服务提供商服务器的IP地址,因此您可以从该IP地址发送到Web服务或用于跟踪该IP地址所在国家/地区的内容.
I solved it by IP Address. You can get the IP address of your phone. If you are using Wi-Fi then it will be the IP address of the Wi-Fi hotspot or IP address of your mobile service provider server, so from that IP address you can send to a web service or something to track the country of that IP address.
如果Internet提供IP地址的国家/地区,则可以使用某些来源(数据库).
There are some sources (database) available if Internet which provides the country of IP address.
以下是示例 http://whatismyipaddress.com/ip-lookup .
这篇关于如何获得国家(或其ISO代码)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!