发送文本消息

为了发送一个文本消息,使用SMS ManagersendTextMessage方法,传入接收者的地址(电话号码)和你想发送的文本消息,如下面的片段所示:

 

String sendTo = 5551234;

String myMessage = Android supports programmatic SMS messaging!;

smsManager.sendTextMessage(sendTo, null, myMessage, null, null);

 

第二个参数用于指定使用的SMS服务中心;上面片段中输入null表示使用默认的服务中心作为你的传送者。

 

最后两个参数允许你指定Intent来追踪消息的发送和成功送达。

 

为了处理这些Intent,创建并注册Broadcast Receiver,如下章节所示。

posted on 2009-10-12 22:33  xirihanlin  阅读(762)  评论(0编辑  收藏  举报