Android sends text messages, calls, and emails.
SMS sending modes include:
1. Use smsmanager to send text messages. The sent text messages are not stored in "information.
2. Use contentresolver to send text messages, which are stored in "information. (The network transfer method is not successful in practice)
3. Use intent to send text messages and call the system's "information" program.
Call modes include:
1. Call an empty dial.
2. Call dial and pass the number.
3. Direct pulling.
Emails sent include:
1. Send a common email.
2. Send attachments.
Package lab. sodino. STM; <br/> Import android. app. activity; <br/> Import android. content. contentresolver; <br/> Import android. content. contentvalues; <br/> Import android. content. intent; <br/> Import android.net. uri; <br/> Import android. OS. bundle; <br/> Import android. telephony. GSM. smsmanager; <br/> Import android. view. view; <br/> Import android. widget. button; <br/> Import android. widget. toast; <br /> Public class extends Act extends activity {<br/>/** called when the activity is first created. */<br/> @ override <br/> Public void oncreate (bundle savedinstancestate) {<br/> super. oncreate (savedinstancestate); <br/> setcontentview (R. layout. main); <br/> (button) findviewbyid (R. id. btnsmsmag) <br/>. setonclicklistener (New button. onclicklistener () {<br/> Public void onclick (view v) {<br/> sendsm S1 (); <br/> toast. maketext (same Act. this, "sent", toast. length_short) <br/>. show (); <br/>}< br/>}); <br/> (button) findviewbyid (R. id. btnsmsinbox) <br/>. setonclicklistener (New button. onclicklistener () {<br/> Public void onclick (view v) {<br/> sendsmsinbox (); <br/> toast. maketext (same Act. this, "sent", toast. length_short) <br/>. show (); <br/>}< br/>}); <br/> (button) findviewbyid (R. id. btnsmsint Ent) <br/>. setonclicklistener (New button. onclicklistener () {<br/> Public void onclick (view v) {<br/> sendsmsintent (); <br/> toast. maketext (same Act. this, "sent", toast. length_short) <br/>. show (); <br/>}< br/>}); <br/> (button) findviewbyid (R. id. btntelempty) <br/>. setonclicklistener (New button. onclicklistener () {<br/> Public void onclick (view v) {<br/> teldialempty (); <br/>}< br/>}); <br /> (Button) findviewbyid (R. id. btntelphone) <br/>. setonclicklistener (New button. onclicklistener () {<br/> Public void onclick (view v) {<br/> teldialphone (); <br/>}< br/> }); <br/> (button) findviewbyid (R. id. btntelcall) <br/>. setonclicklistener (New button. onclicklistener () {<br/> Public void onclick (view v) {<br/> telcall (); <br/>}< br/> }); <br/> (button) findviewbyid (R. id. btnmailsendto) <Br/>. setonclicklistener (New button. onclicklistener () {<br/> Public void onclick (view v) {<br/> mailsendto (); <br/>}< br/> }); <br/> (button) findviewbyid (R. id. btnmailsend) <br/>. setonclicklistener (New button. onclicklistener () {<br/> Public void onclick (view v) {<br/> mailsend (); <br/>}< br/> }); <br/>}< br/> private void sendsms1 () {<br/> // Android is required. permission. send_sms <br/> SMS Manager smsmanager = smsmanager. getdefault (); <br/> smsmanager. sendtextmessage ("10086", null, "1008611", null, null); <br/>}< br/> private void sendsmsinbox () {<br/> // Android is required. permission. read_sms and Android. permission. write_sms, failed to send test <br/> contentvalues values = new contentvalues (); <br/> values. put ("Address", "10086"); <br/> values. put ("body", "bylcx"); <br/> contentresolver = Getcontentresolver (); <br/> // both of them are saved in the Information bar. <Br/> contentresolver. insert (URI. parse ("content: // SMS/sent"), values); <br/> // contentresolver. insert (URI. parse ("content: // SMS/inbox"), values); <br/>}< br/> private void sendsmsintent () {<br/> // jump to "information" without permission. <Br/> intent sendintent = new intent (intent. action_sendto, Uri <br/>. parse ("SMS: //"); <br/> sendintent. putextra ("Address", "10086"); <br/> sendintent. putextra ("sms_body", "bylcs"); <br/> startactivity (sendintent); <br/>}< br/> private void teldialempty () {<br/> // you do not need the permission to jump to "dial. <Br/> intent callintent = new intent (intent. action_call_button); <br/> startactivity (callintent); <br/>}< br/> private void teldialphone () {<br/> // no permission is required, jump to "dial. <Br/> intent callintent = new intent (intent. action_dial, Uri <br/>. parse ("Tel: 10086"); <br/> startactivity (callintent); <br/>}< br/> private void telcall () {<br/> // Android is required. permission. call_phone <br/> intent callintent = new intent (intent. action_call, Uri <br/>. parse ("Tel: 10086"); <br/> startactivity (callintent); <br/>}< br/> private void mailsendto () {<br/> // Android is required. permission. sendto permission <br/> URI uri = Uri. parse ("mailto: 10086@qq.com"); <br/> intent mailintent = new intent (intent. action_sendto, Uri); <br/> startactivity (mailintent); <br/>}< br/> private void mailsend () {<br/> // Android is required. permission. send permission <br/> intent mailintent = new intent (intent. action_send); <br/> // try the difference between "plain/text" and "text/plain". Hey <br/> mailintent. settype ("plain/text"); <br/> string [] arrreceiver = {"10086@qq.com", "10086@qq.com "}; <br/> string [] arrcc = {"10086@qq.com", "10086@qq.com" };< br/> string [] arrbcc = {"10086@qq.com", "10086@qq.com "}; <br/> string mailsubject = "mailsubject"; <br/> string mailbody = "mail sodino test"; <br/> string attachpath = "file: /// sdcard/ucdownloads/atest.apk "; <br/> mailintent. putextra (intent. extra_email, arrreceiver); <br/> mailintent. putextra (intent. extra_cc, arrcc); <br/> mailintent. putextra (intent. extra_bcc, arrbcc); <br/> mailintent. putextra (intent. extra_subject, mailsubject); <br/> mailintent. putextra (intent. extra_text, mailbody); <br/> mailintent. putextra (intent. extra_stream, Uri. parse (attachpath); <br/> mailintent. settype ("audio/MP3"); <br/> startactivity (intent. createchooser (mailintent, "mail sending... "); <br/>}< br/>}
<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: Orientation = "vertical" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "fill_parent" <br/> <textview <br/> Android: TEXT = "SMS" <br/> Android: textsize = "30sp" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> Android: gravity = "center" <br/> <linearlayout <br/> Android: orientation = "horizontal" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> Android: gravity = "center" <br/> Android: Background = "#80808080"> <br/> <button <br/> Android: TEXT = "smsmag" <br/> Android: Id = "@ + ID/btnsmsmag" <br/> Android: gravity = "center" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> </button> <br/> <button <br/> Android: TEXT = "inbox" <br/> Android: Id = "@ + ID/btnsmsinbox" <br/> Android: gravity = "center" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> </button> <br/> <button <br/> Android: TEXT = "intent" <br/> Android: Id = "@ + ID/btnsmsintent" <br/> Android: gravity = "center" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> </button> <br/> </linearlayout> <br/> <textview <br/> Android: TEXT = "tel" <br/> Android: textsize = "30sp" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> Android: gravity = "center" <br/> </textview> <br/> <linearlayout <br/> Android: orientation = "horizontal" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> Android: gravity = "center" <br/> Android: Background = "#80808080"> <br/> <button <br/> Android: TEXT = "emptydial" <br/> Android: Id = "@ + ID/btntelempty" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> Android: gravity = "center" <br/> </button> <br/> <button <br/> Android: TEXT = "phonedial" <br/> Android: Id = "@ + ID/btntelphone" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> Android: gravity = "center" <br/> </button> <br/> <button <br/> Android: TEXT = "call" <br/> Android: Id = "@ + ID/btntelcall" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> Android: gravity = "center" <br/> </button> <br/> </linearlayout> <br/> <textview <br/> Android: TEXT = "mail" <br/> Android: textsize = "30sp" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> Android: gravity = "center" <br/> </textview> <br/> <linearlayout <br/> Android: orientation = "horizontal" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> Android: gravity = "center" <br/> Android: Background = "#80808080"> <br/> <button <br/> Android: TEXT = "sendto" <br/> Android: Id = "@ + ID/btnmailsendto" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> Android: gravity = "center" <br/> </button> <br/> <button <br/> Android: TEXT = "Send (attach)" <br/> Android: Id = "@ + ID/btnmailsend" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> Android: gravity = "center" <br/> </button> <br/> </linearlayout> <br/>