呼叫簡訊編輯介面
intent smsintent = new intent(intent.action_sendto,
uri.parse("sms:5556"));
smsintent.putextra("sms_body", "press send to send me");
startactivity(smsintent);
傳送簡訊比較簡單:
string sent_sms_action = "sent_sms_action";
string delivered_sms_action = "delivered_sms_action";
smsmanager smsmanager = smsmanager.getdefault();
string sendto = "5556";
string mymessage = "android supports programmatic sms messaging!";
// create the sentintent parameter
intent sentintent = new intent(sent_sms_action);
0, sentintent, 0);
// create the deliveryintent parameter
intent deliveryintent = new intent(delivered_sms_action);
0, deliveryintent, 0);
// register the broadcast receivers
registerreceiver(new broadcastreceiver()}},
new intentfilter(sent_sms_action));
registerreceiver(new broadcastreceiver()
},new intentfilter(delivered_sms_action));
// send the message
smsmanager.sendtextmessage(sendto, null, mymessage, sentpi, deliverpi);
接受簡訊要註冊乙個listener:
final string sms_received = "android.provider.telephony.sms_received";
intentfilter filter = new intentfilter(sms_received);
broadcastreceiver receiver = new incomingsmsreceiver();
registerreceiver(receiver, filter);
自定義的listener:
class incomingsmsreceiver extends broadcastreceiver
{ private static final string querystring = "@echo";
private static final string sms_received = "android.provider.telephony.sms_received";
public void onreceive(context _context, intent _intent)
{ if (_intent.getaction().equals(sms_received))
{ smsmanager sms = smsmanager.getdefault();
bundle bundle = _intent.getextras();
if (bundle != null) {
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]);
for (int i=0; i
Android學習 收發簡訊
使用android api類庫可以自己實現收發簡訊的功能 資訊的傳送,對mms應用程式來講主要是在資訊資料庫中建立並維護一條資訊記錄,真正的傳送過程交由底層 frameworks層 函式來處理 雖然在android系統中已經存在傳送簡訊的應用,但是如果我們在開發其他應用時需要整合傳送簡訊功能,則很方...
手機收發簡訊
手機收發簡訊,上一邊文章介紹了簡訊的編碼解碼,在此基礎上編寫了手機收發簡訊的 收發簡訊都是呼叫at指令集。原來設計了乙個版本,收簡訊採用serialport類的datareceive事件,使用at cnmi指令接收短訊息。這樣有個問題,來一條簡訊就會觸發乙個事件,這樣,如果對方發簡訊的頻率過快,特別...
Android 發簡訊功能實現
在自己的應用增加發簡訊功能有兩種方式 1,跳轉到系統簡訊頁面傳送,呼叫如下 即可。intent intent new intent intent.action sendto,uri parse smsto telnum 如果需要將內容傳過去增加如下 intent putextra sms body ...