在Android中比较电话号码 [英] Comparing phone numbers in Android

查看:177
本文介绍了在Android中比较电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要比较两个电话号码,以确定它们是否从同一发送/接收器。用户可以将消息发送给一个联系人,该联系人可以回答。

I need to compare two phone numbers to determine if they're from the same sender/receiver. The user may send a message to a contact, and that contact may reply.

的答复通常是在 +国家 - code] [面积 - code-IF-任何] [和-然后最实际的号码] 格式。例如, +94 71 2593276 为斯里兰卡的电话号码。

The reply usually comes in +[country-code][area-code-if-any][and-then-the-actual-number] format. For example, +94 71 2593276 for a Sri Lankan phone number.

而当用户的发送的消息时,他通常会进入的格式(上面的例子) 0712593276 (假设他也是在斯里兰卡)。

And when the user sends a message, he will usually enter in the format (for the above example) 0712593276 (assume he's also in Sri Lanka).

所以,我需要的是,我需要检查,如果这两个数字都是相同的。这个程序将在国际上使用。所以,我不能只替换第2个数字加上0(那么这将是像美国这样的国家的一个问题)。有没有办法做到这一点在Java或者Android的具体一点吗?

So what I need is, I need to check if these two numbers are the same. This app will be used internationally. So I can't just replace the first 2 digits with a 0 (then it will be a problem for countries like the US). Is there any way to do this in Java or Android-specifically?

感谢。

推荐答案

看看的 http://developer.android.com/reference/android/telephony/PhoneNumberUtils.html ,看看有没有你想要做什么。

Take a look at http://developer.android.com/reference/android/telephony/PhoneNumberUtils.html and see if that does what you want.

这篇关于在Android中比较电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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