检查是否调用正在为国际 [英] Checking if call being made is international

查看:160
本文介绍了检查是否调用正在为国际的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查,如果一个呼叫正在为国际或不是。我有我获得通过TelephonyManager.getLine1Number的SIM卡号码(),也是国家code中的SIM卡,我得到使用TelephonyManager.getSimCountryIso()ISO。

I'd like to check if a call being made is international or not. I have the SIM number which I obtain by using TelephonyManager.getLine1Number() and also the Country code ISO of the SIM Card which I obtain using TelephonyManager.getSimCountryIso().

反正是有,我可以找到号码的国家code正在取得到的电话吗?

Is there anyway I can find the country code of the number to which the call is being made?

推荐答案

我不认为 telephonyManager.getSimCountryIso()将帮助您确定哪个国家的呼叫正在取得',因为它会返回国家的ISO。

I don't think telephonyManager.getSimCountryIso() would help you determine 'to which country the call is being made' as it will return your country's ISO.

此外,政府新闻处codeS的长度不同国家而有所不同。对于一些国家来说是1,对一些人来说是2,对一些人来说是3和他人是4。所以你需要解压/让4个不同的呼出号码,这些长度的密钥,因为我已经证明如下:

Moreover, length of ISD codes vary across countries. For some countries it is 1, for some it's 2, for some it's 3 and for others it's 4. So you will need to extract/make 4 different keys of these lengths from the outgoing number as I have shown below:

说出了去电号码为+ 91-XXX-XXX-XXXX。 那么您将创建4个按键为:

Say the out going number is +91-XXX-XXX-XXXX. then you'll create 4 keys as:

  1. 9 (1位密钥)
  2. 91 (2位密钥)
  3. 91X (3数字键)
  4. 91XX (4数字键)
  1. 9 (1 digit key)
  2. 91 (2 digit key)
  3. 91X (3 digit key)
  4. 91XX (4 digit key)

现在检查是否有这4个按键为present在此列表中:的 ISO列表

Now check if any of these 4 keys is present in this list: ISO List.

同样,如果你只需要确定该呼叫正在为国际或没有,那么你可以简单地检查以下条件:

Again, if you only need to determine if the call being made is international or not then you can simply check for below condition:

if(outgoing-number `startswith` "00" || outgoing-number does not `startswith` your "country's-ISD-code") {
    //it's an international call;
} else {
    //it's a domestic call;
}

这篇关于检查是否调用正在为国际的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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