如何获取手机号码的Andr​​oid? [英] How to obtain Phone Number in Android?

查看:103
本文介绍了如何获取手机号码的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个扩展的问题<一href="http://stackoverflow.com/questions/6329216/how-to-obtain-mobile-number-of-own-device-in-android">here.现在,我引用 CommonsWare

  

没有可靠的方法来检索设备编程的移动电话号码。唯一的选择剩下的,我能想到的是获取用户输入的电话号码的。

我的问题是,如何检查,如果用户输入的电话号码是正确的,这些和更多的可能性,我现在不能想:

  1. 由用户输入的数字是相同的设备应用程序被下载对
  2. 用户同时输入号码
  3. 没有作出任何打字错误
  4. 在用户没有输入任何洗护code像龙头0

我有花足够的时间在计算器和网络,这是不是一个重复的问题。

我会AP preciate任何帮助,线索或建议。

解决方案
  

用户输入1,编号是相同的设备应用程序被下载对

这又是一种无法测试的东西,否则由@neteinstein提到的整蛊方式


  

2.用户在输入数量没有作出任何打字错误

     

3.用户没有输入任何洗护code像龙头0

我想你还没有意识到这一点的 由谷歌,使用的解析/格式化/验证电话号码的所有国家/世界各地区。

使用,你可以achive你的其他2 solutions.I认为。


链接: HTTP://$c$c.google.com/p/libphonenumber /

This is an extension to the question here. Now I quote CommonsWare

There is no reliable way to retrieve mobile number of device programatically. The only option remaining and I can think of is getting user to input for the phone number.

My question is how to check if the phone number entered by the user is correct for these and any more possibilities which I cannot think now:

  1. The number entered by the user is of the same device the app has been downloaded on.
  2. User did not make any typographical error while entering the number
  3. User did not enter any local calling code like leading 0

I have spend sufficient time on StackOverflow and web and this is not a duplicate question.

I will appreciate any help, clues or suggestions.

解决方案

1.The number entered by the user is of the same device the app has been downloaded on.

Again this is something kind of impossible to test, else the Tricky way mentioned by @neteinstein


2.User did not make any typographical error while entering the number

3.User did not enter any local calling code like leading 0

I think you still not aware of this library by google,used for Parsing/formatting/validating phone numbers for all countries/regions of the world.

Using that you can achive your other 2 solutions.I think.


Link : http://code.google.com/p/libphonenumber/

这篇关于如何获取手机号码的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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