可能重复:
检测短信传入和传出
我想读取传入的短信以检查短信中是否存在特定值
我发现这个短信接收代码我想检查接收短信是否具有以下值 xml 值
请帮助我如何检查
//this is response which i check in reciving sms
00
LOG
00
Adeel Aslam
10.00
10/05/2012 10:00
+100
//this is code which i found for sms recive
public class SmsReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
//---get the SMS message passed in---
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
if (bundle != null)
{
//---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i=0; i<msgs.length; i++){
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
str += "SMS from " + msgs[i].getOriginatingAddress();
str += " :";
str += msgs[i].getMessageBody().toString();
str += "\n";
}
//---display the new SMS message---
Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
}
}