发送文本消息

mac2022-06-30  85

为了发送一个文本消息,使用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,如下章节所示。

转载于:https://www.cnblogs.com/xirihanlin/archive/2009/10/12/1582073.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)