我在android應用程序的短信中遇到了一個小問題。我需要您的幫助來接收我向其發送消息的配方地址。短信android接收函數
示例代碼如下。
public void oncall() {
// public void onReceive(Context context, Intent intent) {
// ---get the SMS message passed in---
Bundle bundle = new Bundle(); // intent.getExtras();
SmsMessage[] msgs;
// 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]);
String Mobno = msgs[i].getOriginatingAddress();
// String message = msgs[i].getMessageBody().toString();
output.setText("" + Mobno);
}
// ---display the new SMS message---
// Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
}
}
什麼錯誤u的越來越u的使用字符串Mobno =封郵件[I] .getOriginatingAddress();你將獲得手機號碼 – user1203673 2012-03-05 07:07:39
沒有錯誤的描述... -1。 – JoxTraex 2012-03-05 07:16:49
我在做類似的事情! http://stackoverflow.com/questions/14452808/sending-and-receiving-mms-in-android – toobsco42 2013-01-22 08:13:07