本文介绍了如何获得CDMA Android设备的国家/地区代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取CDMA网络下Android设备的国家/地区代码信息?

How can I retrieve the country code information for Android devices under CDMA networks?

对于其他所有人,您只需使用 TelephonyManager :

For all others, you can just use the TelephonyManager for that:

String countryCode = null;
TelephonyManager telMgr = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (telMgr.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA)
    countryCode = telMgr.getNetworkCountryIso();
}
else {
    // Now what???
}

我进行了一些搜索,但没有找到任何有用的信息来得出答案.

I searched a bit, but I did not find any useful information that would lead to an answer.

有些想法要记住:

  • GPS位置:您可以从 GeoCoder 获取国家/地区;和
  • IP地址:有一些不错的API可以获取它,例如 ipinfodb .
  • GPS location: you can get the country from GeoCoder; and
  • IP address: there are some nice APIs to get it, such as ipinfodb.

这些可以使用还是有更好的呢?

Could these be used or are there better ones?

推荐答案

它适用于CDMA,但并非总是如此-它取决于网络运营商.

It works for CDMA, but not always - it depends on the network carrier.

这是另一种想法,这表明查看传出短信或通话找出该设备的电话号码,然后您就可以根据国际拨号代码从该号码中找出CountryIso ...

Here's an alternative idea, which suggests looking at the outgoing SMS or calls to figure out this device's phone number, from which you can then figure out the CountryIso based on the international dialing code...

这篇关于如何获得CDMA Android设备的国家/地区代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 16:12