send message between two emulator android

send message between two emulator android

send message between two emulator android

send a message between two emulator android is working same as sending a message from one mobile to another mobile. Here in case of sending a message between emulators you need to use emulator port number instead of the mobile number because emulators can be identified by their port.  Follow the steps to send a message between two or more emulators.

Step 1: Start AVD

Step 2: Again Start AVD (for example if you run AVD First time it will be assigned port like 5554 and second-time port may be 5556)

Step 3: If you want to send a message from 5554 to 5556 then you need to go to emulator 5554, Message -> Compose and write the mobile number as 5556 and message hit Send Button.

Step 4: Add following permission into your AndroidManifest.xml

<uses-permission android:name=”android.permission.SEND_SMS”/>


Step 5 : Write down following code and Run your project in emulator 5554

Location : src\package\

FileName :

package com.example.gtu_android_prog21;

*  send message between two emulator android
*  Create an application to send message between two emulators.
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends Activity {

PendingIntent pi;
SmsManager sms;

protected void onCreate(Bundle savedInstanceState) {


//    Get all pending Activity
String msg = “android.telephony.SmsManager.STATUS_ON_ICC_SENT”;
PendingIntent piSent = PendingIntent.getBroadcast(MainActivity.this, 0,new Intent(msg), 0);

//    Send SMS Using Default SMS Manager
sms = SmsManager.getDefault();
sms.sendTextMessage(“5556”, null, “This is sample test message”, piSent, null);

public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(, menu);
return true;

public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == {
return true;
return super.onOptionsItemSelected(item);


Location : res\layout

FileName: activity_main.xml

<RelativeLayout xmlns:android=””
tools:context=”com.example.gtu_android_prog21.MainActivity” >

android:text=”Send Message to emulators programmatically”
android:textAppearance=”?android:attr/textAppearanceLarge” />



Output 1 : Emulator Screen shot of 5554

send message between two emulator android


Output 2 : Emulator Screenshots of 5556

send message between two emulator android



Adarsh Patel

My Self Adarsh Suryakant Patel. Currently I am working as Assistant Professor at Parul Instiute of Engineering and Technology, MCA Department, Limda, Vadodara. Major Responsibility : * Lectures * Organizing Training and Expert Sessions for * Placement and Recruitment * Faculty Representative