WEB开发网      濠电娀娼ч崐濠氬疾椤愶附鍋熸い鏍ㄧ〒闂勫嫰鏌﹀Ο渚Ц闁诲氦顕ч湁婵犲﹤楠告禍鍓х磼鏉堛劌绗氶柟宄版嚇閹晠宕归銈嗘濠电偞鍨堕幐鎾磻閹捐秮褰掓偐閻戞﹩妫勯梺鎼炲妼鐎涒晝绮嬪澶樻晝闁挎繂鏌婇敃鍌涚厵閻庢稒锚閻忥絾绻濇繝鍐ㄧ伌闁诡垰鍟村畷鐔碱敂閸♀晙绱樺┑鐐差嚟婵儳螞閸曨剚鍙忛柍鍝勬噹缁€澶嬬箾閹存繄锛嶆鐐灲閹綊宕惰濡插鏌涢妸銉ヮ劉缂佸倸绉归弫鎾绘晸閿燂拷 ---闂備焦瀵уú鈺呭箯閿燂拷
开发学院手机开发Android 开发 Android发送短信与邮件 阅读

Android发送短信与邮件

 2010-11-05 00:54:29 来源:WEB开发网 闂備線娼уΛ鎾箯閿燂拷闂備礁鎲¢崹鐢垫崲閹扮増鍎嶆い鎺戝€甸崑鎾斥槈濞嗗秳娌紓鍌氱▌閹凤拷濠电姭鎷冮崨顓濈捕闂侀潧娲ゅú銊╁焵椤掍胶鈯曢柕鍥╁仧缁辩偤鏁撻敓锟�闂備線娼уΛ鎾箯閿燂拷  闂備胶枪缁绘鈻嶉弴銏犳瀬闁绘劕鎼痪褔鏌曟繝蹇曠窗闁煎壊浜滈—鍐偓锝庡墮娴犙勭箾閸喎鐏ユい鏇樺劦椤㈡瑩鎮℃惔銇帮拷
核心提示:Java代码发送短信:SmsManager smsMgr = SmsManager.getDefault();smsMgr.sendTextMessage(address, null, message, null, null);显示写短信界面:Uri smsToUri = Uri.parse("smsto:/

Java代码

发送短信:

SmsManager smsMgr = SmsManager.getDefault();

smsMgr.sendTextMessage(address, null, message, null, null);

显示写短信界面:

Uri smsToUri = Uri.parse("smsto://10086");

Intent mIntent = new Intent( android.content.Intent.ACTION_SENDTO, smsToUri );

startActivity( mIntent );

发送电子邮件:

Intent i = new Intent(Intent.ACTION_SEND);

i.putExtra(Intent.EXTRA_EMAIL, address);

i.putExtra(Intent.EXTRA_SUBJECT, filename);

i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + filename)); ;

i.setType("text/csv");

startActivity(Intent.createChooser(i, "EMail File"));

Android API - SMS handling

Many new application will use SMS as data delivery platform. Reality shows, on-demand movies etc request users to send predefined formatted SMS. Similarly some applications are coming up which sends data to user using SMS. Let’s see how such an application can be built using Android platform.

Android API support developing applications that can send and receive SMS messages. The android emulator does not support sending of the SMS currently. But the emulator can receive SMS. Lets explore the android SMS support and develop a small program that listens to the SMSes received on the device (on emulator) and will show that message as notification.

The event handling on Android is done with the help of intents and intent receivers. The intents announce (or broadcast) the event and intent receivers respond to the event. Intent receivers act as the event handlers.

Let’s define an intent receiver that can handle the SMS received event:

Code: Select all

package com.wissen.sms.receiver;

/**

* The class is called when SMS is received.

*/

public class SMSReceiver extends BroadcastReceiver {

1 2  下一页

Tags:Android 发送 短信

编辑录入:coldstar [复制链接] [打 印]
赞助商链接