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

相关文章:

  • 2022-12-23
  • 2021-10-30
  • 2021-05-20
  • 2022-03-02
  • 2022-02-11
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-06-11
  • 2022-12-23
  • 2021-10-09
相关资源
相似解决方案