因此,在我的應用程序中,我對傳入的短信做出了響應,並且希望能夠響應由電子郵件地址發送的短信,但isEmail()始終返回false,因此getEmailFrom()和getEmailBody()總是返回null。這裏是我的代碼:SmsMessage.isEmail()總是返回false
Bundle bundle = intent.getExtras();
String recMsgString = "";
String fromAddress = "";
String tag = "SMS_RECEIVED";
if (bundle != null)
{
//---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
for (int i=0; i<pdus.length; i++){
SmsMessage recMsg = SmsMessage.createFromPdu((byte[])pdus[i]);
recMsgString = recMsg.getMessageBody();
fromAddress = recMsg.getOriginatingAddress();
if (recMsg.isEmail()){
fromAddress = recMsg.getEmailFrom();
recMsgString = recMsg.getEmailBody();
}
}
//do some logging
//code to react to the message
}
}
任何幫助將不勝感激。
你弄明白了嗎? – Jack