Chinaunix首页 | 论坛 | 博客
  • 博客访问: 230545
  • 博文数量: 56
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 375
  • 用 户 组: 普通用户
  • 注册时间: 2014-10-26 20:56
个人简介

http://www.csdn.net/ http://www.arm.com/zh/ https://www.kernel.org/ http://www.linuxpk.com/ http://www.51develop.net/ http://linux.chinaitlab.com/ http://www.embeddedlinux.org.cn http://bbs.pediy.com/

文章分类

全部博文(56)

文章存档

2018年(3)

2017年(12)

2016年(4)

2015年(22)

2014年(15)

分类: Android平台

2014-12-13 09:51:00

用 android 实现短信发送功能时,程序在调用 sendTextMessage 就退出,短信发送不成功。

                 SmsManager smsManager = SmsManager.getDefault();
                 String strTel="1580928152X";           //电话号码    
                 String strMsg="xx说 :Hello Word!!";    //短信内容           
                 smsManager.sendTextMessage(strTel, null, strMsg, null, null);   

原因 如下:

添加程序的发送短信功能需要在程序的主配置文件 AndroidManifest.xml内添加,发送短信权限。
如下:

   

    添加在与标签平级目录下



附:

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

Since: API Level 4

Send a text based SMS.

Parameters
destinationAddress 发送短信的地址(也就是号码)
scAddress 短信服务中心,如果为null,就是用当前默认的短信服务中心
text 短信内容
sentIntent 如果不为null,当短信发送成功或者失败时,这个PendingIntent会被广播出去成功的结果代码是Activity.RESULT_OK,或者下面这些错误之一  :RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
对于 RESULT_ERROR_GENERIC_FAILURE,  the这个sentIntent可能包括额外的"errorCode",包含一些具体有用的信息帮助检查 。基于SMS控制的全部程序检查 sentIntent. 如果 sentIntent 为空,the caller will be checked against all unknown applications, which cause smaller number of SMS to be sent in checking period.
deliveryIntent 如果不为null,当这个短信发送到接收者那里,这个PendtingIntent会被广播,状态报告生成的pdu(指对等层次之间传递的数据单位)会拓展到数据("pdu")



阅读(2623) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~