1. call;
Edittext mobiletext = (edittext) findviewbyid (R. Id. Mobile );
String mobile = mobiletext. gettext (). tostring ();
Intent intent = new intent ();
Intent. setaction ("android. Intent. Action. Call ");
Intent. setdata (URI. parse ("Tel:" + mobile ));
Startactivity (intent );
2. send text messages
Edittext mobiletext = (edittext) findviewbyid (R. Id. Mobile );
Edittext contenttext = (edittext) findviewbyid (R. Id. content );
String mobile = mobiletext. gettext (). tostring ();
String content = contenttext. gettext (). tostring ();
Smsmanager = smsmanager. getdefault ();
Arraylist <string> texts = smsmanager. dividemessage (content); // split the SMS
For (string text: texts ){
Smsmanager. sendtextmessage (mobile, null, text, null, null );
}
You must declare in androidmanifest: <uses-Permission Android: Name = "android. Permission. send_sms"/>
3. receive SMS:
Public class smsreceiver extends broadcastreceiver
{
@ Override
Public void onreceive (context, intent)
{
If ("android. provider. telephony. sms_received"
. Equals (intent. getaction ()))
{
String phonenumber = NULL;
String message = NULL;
// Receives data transmitted by SMS.
Bundle bundle = intent. getextras ();
// Determine whether data exists
If (bundle! = NULL)
{
// All received SMS messages can be obtained through PDUS.
Object [] objarray = (object []) bundle. Get ("PDUS ");
/* Construct the SMS object array and create the array size based on the length of the received object */
Smsmessage [] messages = new smsmessage [objarray. Length];
For (INT I = 0; I <objarray. length; I ++)
{
Messages [I] = smsmessage
. Createfrompdu (byte []) objarray [I]);
}
For (smsmessage currentmessage: messages)
{
Phonenumber = currentmessage. getdisplayoriginatingaddress ();
Message = currentmessage. getdisplaymessagebody ();
}
}
Toast. maketext (context, "Number =" + phonenumber + "MSG =" + message, Toast. length_long). Show ();
}
}
} You must declare in androidmanifest: <uses-Permission Android: Name = "android. Permission. receive_sms"/>