Android的 - 从短信中提取文本 [英] Android - Extract text from SMS
本文介绍了Android的 - 从短信中提取文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够从收到短信的提取文本。
我不知道我是否应该使用内容提供商或包括在通过广播接收器接收到的意图的短信。
I want to be able to extract text from received SMS's. I'm not sure whether I should use content providers or the sms message is included in the intent received by broadcast receiver.
我有一个广播接收器等短信的,并要检查收到的邮件的内容。
I have a broadcast receiver waiting for SMS's, and want to inspect the contents of the received message.
感谢您。
推荐答案
您可以创建的 SmsMessage
从的 意图
在你的 广播接收器
如下:
You can create SmsMessage
instances from the Intent
in your BroadcastReceiver
as follows:
Bundle bundle = intent.getExtras();
Object[] pdus = (Object[])bundle.get("pdus");
SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < pdus.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
//messages[i].getMessageBody();
}
这篇关于Android的 - 从短信中提取文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文