Android:如何从收到的短信中获取电话号码?
我有一个广播接收器 SMSApp,它的 onReceive 会从意图中读取bundleExtras。在这里,我如何从bundleExtras中读取电话号码?
if(intent.getAction().equals(SMS_RECEIVED))
{
Bundle bundleExtras = intent.getExtras();
if (bundleExtras != null)
{
}
}
I have a broadcast receiver SMSApp which onReceive reads bundleExtras from intent. Here, How can I read phone number from bundleExtras?
if(intent.getAction().equals(SMS_RECEIVED))
{
Bundle bundleExtras = intent.getExtras();
if (bundleExtras != null)
{
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
现在,
messages[0].getOriginatingAddress()
是地址,messages[0].getMessageBody()
是消息正文。Now,
messages[0].getOriginatingAddress()
is the address andmessages[0].getMessageBody()
is the message body.教程位于 http://ukitech.blogspot.com/2014/11/android -sms-app.html
输出:
SmsReceiver.processReceivedSms:来自+1650815xxxx的短信
SmsReceiver.processReceivedSms:短信正文测试4
/**
* 由 uki 于 2014 年 11 月 22 日创建。
*/
公共类 SmsReceiver 扩展了 BroadcastReceiver {
Tutorial at http://ukitech.blogspot.com/2014/11/android-sms-app.html
OUTPUT:
SmsReceiver.processReceivedSms﹕ SMS from +1650815xxxx
SmsReceiver.processReceivedSms﹕ SMS body Test 4
/**
* Created by uki on 11/22/14.
*/
public class SmsReceiver extends BroadcastReceiver {
这是详细“如何发送和接收短信”的链接,您应该检查它,它完整且充满示例:
http://mobiforge.com/developing/story/sms-messaging-android
也使用这个 链接,您可以执行以下操作:
This is a link to a detailed "how to send and receive sms messages", you should check it, it is complete and full with examples:
http://mobiforge.com/developing/story/sms-messaging-android
also using this link, you can do: