Android 發簡訊功能實現

2021-07-10 06:06:12 字數 1466 閱讀 3250

在自己的應用增加發簡訊功能有兩種方式:

1,跳轉到系統簡訊頁面傳送,呼叫如下**即可。

intent intent = new intent(intent.action_sendto, uri

.parse("smsto:" + telnum));

// 如果需要將內容傳過去增加如下**

intent .putextra(

"sms_body"

, body);  

startactivity(intent);

2,呼叫系統發簡訊介面sendtextmessage。activity如下:

布局檔案就是兩個輸入框和乙個傳送按鈕。

androidmanifest.xml需要許可權

public class maintestactivity extends activity

sendsms(phone,content);

}});

//註冊簡訊傳送狀態的廣播

mreceiver = new smssendresultreceiver();

intentfilter filter = new intentfilter(sent_sms_action);

registerreceiver(mreceiver, filter);

}/** 

* 直接呼叫簡訊介面發簡訊    如果**可以迴圈呼叫

* @param phonenumber 

* @param message 

*/  

public void sendsms(string phonenumber,string message)  

}smssendresultreceiver mreceiver;

// 監聽簡訊傳送狀態

class smssendresultreceiver extends broadcastreceiver    }

}}@override

protected void ondestroy() }}

sendtextmessage的引數說明:

public void 

sendtextmessage

(string destinationaddress, 

string scaddress, string text,pendingintent sentintent, pendingintent deliveryintent)

destinationaddress: 收件人位址 

scaddress: 簡訊中心號碼,null為預設中心號碼

sentintent: 當訊息發出時,成功或者失敗的資訊報告通過pendingintent來廣播。如果該引數為空,則發信程式會被所有位置程式檢查一遍,這樣會導致傳送時間延長。 

deliveryintent: 當訊息傳送到收件人時,該pendingintent會被廣播。pdu資料在狀態報告的extended data ("pdu")中。

Android收發簡訊

呼叫簡訊編輯介面 intent smsintent new intent intent.action sendto,uri.parse sms 5556 smsintent.putextra sms body press send to send me startactivity smsintent...

android打電話 發簡訊實現

intent intent newintent intent.action call,uri.parse tel 156666666666 this.startactivity intent 加上打 的許可權 發簡訊 發簡訊 string content 1111111111111111111111...

Android學習 收發簡訊

使用android api類庫可以自己實現收發簡訊的功能 資訊的傳送,對mms應用程式來講主要是在資訊資料庫中建立並維護一條資訊記錄,真正的傳送過程交由底層 frameworks層 函式來處理 雖然在android系統中已經存在傳送簡訊的應用,但是如果我們在開發其他應用時需要整合傳送簡訊功能,則很方...