如何获得ISO国家code Android应用程序? [英] How to get ISO Country code in android applications?

查看:393
本文介绍了如何获得ISO国家code Android应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android应用程序中的新的开发。我想获得ISO国家code,当我通过手机号码与国家code。如果我通过手机号码为1-319-491-6338,我可以得到国家ISO code,因美国/美国在机器人?

I am a new developer on android application. I would like to get the ISO Country code when I pass the mobile number with country code. If I pass the mobile number as 1-319-491-6338, can I get country ISO code as US / USA in android?

我已经写了code如下:

I have written the code as follows:

      TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
      String countryCode = tm.getSimCountryIso();
      String mobileno="1-319-491-6338";

在这里,我在这里可以通过手机号码?

Here, where can I pass the mobile number?

谁能帮帮我吗?

在此先感谢

推荐答案

您可能无法查询全国code通过编程的标准API,但你可以有一个表中的应用程序。这种表很容易通过谷歌找到。(如: HTTP://country$c$c.org/

You may not be able to query the country code programmatically via the standard API but you could include a table in your app. Such a table is easily found via Google (e.g. http://countrycode.org/).

危险就会罗宾逊:但是,你应该问自己:什么问题你要回答。隐在的问题是,假设有国际长途codeS和ISO国家codeS之间有一个一对一的映射。这是不可以真。例如,无论是美国和加拿大的国际长途code'1'。

Danger Will Robinson!: However, one should ask yourself what question you are trying to answer. Implicit in your question is that assumption that there is a one-to-one mapping between international dialling codes and ISO country codes. This is not true. For example, both the USA and Canada have the international dialling code '1'.

也许想重新构建你的应用程序的界面。允许用户选择一个国家,与手机号码关联,但使用该表从 HTTP://country$c$c.org/ 命令上方最有可能的人选?

Perhaps think about re-structuring your app's interface. Allow the user to select a country to associate with the phone number but use the table from http://countrycode.org/ to order the most likely candidates at the top?

这篇关于如何获得ISO国家code Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆