Download Code

SMS Call Message Intent Android

In sms call message intent android tutorial you will learn how to send an sms/call from android application.You must have some knowledge of Intent.First i’ll give some information about classes(SMSManager,Intent) which you will use to send an message or make a call from android application.

SMS Manager

SMSManager Manages operations such as sending data, text, and pdu messages.

Get this object by calling the static method SmsManager.getDefault().

Intent

An intent is an abstract description of an operation to be performed.Some operations are.

  • ACTION_DIAL
  • ACTION_VIEW
  • ACTION_EDIT
  • ACTION_CALL

Create new sms call message intent android application project.Go to activity_main.xml and add components.

  • EditText(Two)
  • Button(Two)

sms,call,sms in android,call in android,how to send sms android, how to send sms in android,how to send sms android tutorial, how to make a call android,how to make a call in android tutorial, SMSmanager,how to send sms using sms manager,how to send an sms using smsmanager in android,how to send sms android tutorial,Call intent, uri,how to call in android application,how to call using call intent, how to call using call intent in android application, how to make a call android tutorial,send sms android,send sms android tutorial, call android,call intent android,call android tutorial,call intent android tutorial, smsmanager.getdefault,smsmanager.getdefault in android,SMS call,sms call message,sms call message intent,sms call message intent android,

Next go to MainActivity.java. Do the following steps.

  • Create variable for EditText,Button.
  • Refer id’s of EditText and Button.
  • Apply click Event on Button.
  • Use SMS Manager class to send an sms.
  • Use ACTION_CALL intent to make a call.

MainActivity.java

package developer.codecsmscall;

import android.support.v7.app.ActionBarActivity;
import android.telephony.SmsManager;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


public class MainActivity extends Activity implements OnClickListener{

	EditText userMsg,userNum;     // Edit text variable for user message and number
	Button smsBtn,callBtn;        // sms and call button variable
	String no;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		initialize();   // method to refer and apply click event on UI Components
	}
	public void initialize(){
		userMsg = (EditText) findViewById(R.id.msg);
		userNum = (EditText) findViewById(R.id.number);
		smsBtn = (Button) findViewById(R.id.sms);
		callBtn = (Button) findViewById(R.id.call);
		smsBtn.setOnClickListener(this);
		callBtn.setOnClickListener(this);
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
		case R.id.sms:
			if(!(userNum.getText().toString().equals("")) && !(userMsg.getText().toString().equals(""))){
				no = userNum.getText().toString();
				String userMessage = userMsg.getText().toString();
				SmsManager smManager = SmsManager.getDefault();
				// sending text message
				smManager.sendTextMessage(no, null, userMessage, null, null); 
			}
			else{
				Toast.makeText(getApplicationContext(), "Empty Fields", Toast.LENGTH_SHORT).show();
			}
			break;
		case R.id.call:
			if(!(userNum.getText().toString().equals(""))){
				no = userNum.getText().toString();
				// call intent to start call action
				Intent callInt = new Intent(Intent.ACTION_CALL);
				callInt.setData(Uri.parse("tel:"+ no));
				startActivity(callInt);
			}
			else{
				Toast.makeText(getApplicationContext(), "Please enter number", Toast.LENGTH_SHORT).show();
			}
			break;
		}
	}


}

Run your android application project.

sms,call,sms in android,call in android,how to send sms android, how to send sms in android,how to send sms android tutorial, how to make a call android,how to make a call in android tutorial, SMSmanager,how to send sms using sms manager,how to send an sms using smsmanager in android,how to send sms android tutorial,Call intent, uri,how to call in android application,how to call using call intent, how to call using call intent in android application, how to make a call android tutorial,send sms android,send sms android tutorial, call android,call intent android,call android tutorial,call intent android tutorial, smsmanager.getdefault,smsmanager.getdefault in android,SMS call,sms call message,sms call message intent,sms call message intent android,
That’s it for this tutorial.
Thanks.