老问题,新总结,获取本机号码

1.[url]http://www.ityoudao.com/Web/Android_657_2001.html[/url]

本文中所讲的需求简单,明了,我说的简单指的是只有一个需求,不复要,不复合,就是一个,取得本机号码,请你看下面这代码

TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// 获取手机号码

String phoneId = tm.getLine1Number();
Log.i(phoneId,phoneId);

你猜会怎么样,取不到!奇怪吧,神奇吧~~~怎么的的,你就是没有办法取得本机号码,这是为什么呢,有何良策,我心里在想啊,肿么办!

我静心一想解决问题得找到问题所在,不然无从下手...经我google/baidu,找到了基本的原因和曲线救国之解决方法,现逻列如后:
第一点:造成原因
能否取得手机号码依赖于运营商是如何制作SIM卡的,所以有的可以取出,有的则不行。看吧,这不全是你的错,哈哈~~~
第二点:解决方案
给10086发个短信就行了,然后获取发件箱中的发件人号码...反正给10086发短信或者打电话是免费的 ,但是你得注意了
1、获取发件箱中的发件人号码后你得把发件箱中记录删除;
2、就是你还要拦截10086给你回复的短信,不然会有个notification显示在屏幕上方,提示10086发来个短信,让你查看;
这些都是为了取得本机号码的任务下,但同时又提高了用户的体验度...明白吗?

===================================================
[color=red]这个可能才是终极的解决办法吧。。。。呵呵[/color]


public void sendTextMessage (String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)

Since: API Level 4
Send a text based SMS.

Parameters
destinationAddress the address to send the message to
scAddress is the service center address or null to use the current default SMSC
text the body of the message to send
sentIntent if not NULL this PendingIntent is broadcast when the message is successfully sent, or failed. The result code will be Activity.RESULT_OK for success, or one of these errors:
RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
For RESULT_ERROR_GENERIC_FAILURE the sentIntent may include the extra "errorCode" containing a radio technology specific value, generally only useful for troubleshooting.
The per-application based SMS control checks sentIntent. If sentIntent is NULL the caller will be checked against all unknown applications, which cause smaller number of SMS to be sent in checking period.
deliveryIntent if not NULL this PendingIntent is broadcast when the message is delivered to the recipient. The raw pdu of the status report is in the extended data ("pdu").
Throws
IllegalArgumentException if destinationAddress or text are empty

[url]http://www.open-open.com/lib/view/open1332139318999.html[/url]
[url]http://www.2cto.com/kf/201203/121892.html[/url]


这篇文章很有参考意义
[url]http://jessical08.iteye.com/blog/877138[/url]
[url]http://blog.csdn.net/sodino/article/details/5871537[/url]
全国短信中心号码
[url]http://zdm2008.blog.163.com/blog/static/20491545201062210921272/[/url]

Android中怎样取本机的手机号码
[url]http://www.cppblog.com/fwxjj/archive/2011/01/27/139433.html[/url]

android中短信协议与字段
[url]http://blog.csdn.net/tianqixin/article/details/6705899[/url]
Android短信数据字段
[url]http://xmj101.iteye.com/blog/1382431[/url]


----------------------------------------------------------
eoe的问题:
[url]http://www.eoeandroid.com/thread-181202-1-1.html[/url]
[color=red]android 短信字段 貌似没有收件人号码这个字段。。。。。貌似短信获取本机号,也不是很现实,也只有让用户自行输入了。。。。[/color]


[url]http://edison-cool911.iteye.com/blog/751644[/url]
这个总结的非常好。。。不错
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值