Package COM. example. demointent; import android. app. activity; import android. content. intent; import android.net. uri; import android. OS. bundle; import android. view. menu; import android. view. view; import android. view. view. onclicklistener; import android. widget. button; import android. widget. edittext; public class mainactivity extends activity {private button button1; // send a private button button2; // call private edittext ET1; private edittext et2; private string strsms; private string strphone; @ overridepublic void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); super. setcontentview (R. layout. activity_main); this. button1 = (button) findviewbyid (R. id. button1); this. button2 = (button) findviewbyid (R. id. button2); this. ET1 = (edittext) findviewbyid (R. id. edittext1); this. et2 = (edittext) findviewbyid (R. id. edittext2); this. button1.setonclicklistener (New onclicklistener () {public void onclick (view v) {strsms = et1.gettext (). tostring (); // strphone = et2.gettext (). tostring (); // phone number // The first method. There is an interface for you to choose whether to send URI uri = Uri. parse ("smsto:" + strphone); intent = new intent (); intent. putextra ("sms_body", strsms); // sets the intent of the text message. setaction (intent. action_sendto); intent. setdata (URI); startactivity (intent); // The second method is directly sent. // smsmanager = smsmanager. getdefault (); // pendingintent = pendingintent. getbroadcast (// mainactivity. this, 0, new intent (), 0); // smsmanager. sendtextmessage (strphone, null, strsms, // pendingintent, null) ;}}); this. button2.setonclicklistener (New onclicklistener () {public void onclick (view v) {strsms = et1.gettext (). tostring (); // strphone = et2.gettext (). tostring (); // phone number URI uri = Uri. parse ("Tel:" + strphone); intent = new intent (intent. action_call, Uri); // Note: The call is played directly, and the dial is determined by the system before startactivity (intent );}});} @ overridepublic Boolean oncreateoptionsmenu (menu) {getmenuinflater (). inflate (R. menu. activity_main, menu); Return true ;}}