Saturday, January 12, 2008

SMS Emulation on Android


When we are trying to test SMS based program on Android, we have to simulate receiving SMS. Fortunately, with new SDK, we can simulate the SMS come to Emulator. We have just to connect to emulator using telnet and there we can emulate the SMS. Below step by step to emulate the SMS:
  • Start the emulator, you free to give the option, For example just type emulator on shell prompt
  • Open a new shell and type :

    adb devices

    to know the port emulator used. The console of the first emulator instance running on a given machine uses 5554 port, The command above just to make sure which port the instance used.
  • Connect to the console using telnet command like:
    telnet localhost 5554
  • After you have come to the shell you can emulate sms with command:

    sms send <phonesender> <text message>
Ok, Good luck with your try, and Hope, One of Use will win the Android Google Challenge!

7 comments:

mikea said...

Can you send an sms message using this emulation?

Bhayangkara said...

No, you can't.
This feature is just to emulate an incoming message to our emulator, than we can create a program/ to handle the incoming message. So, when the Android phone is come, we can upload the sms handle program we created to handle every incoming message to our phone.

Parasu said...

Hi Thanks for your post, bcos, really usefull for the beginers.

Thanks

Anonymous said...

Thanks. Any idea if we can do something for voicemail?

dujavi said...

Hi there, I am trying to enter this command:
sms send +573118768198 hello

but systems returns this error:
bad phone number format

any clue? Thanks

Bhayangkara said...

Hi too ..
Try to omit '+'
good luck with your try.

Anonymous said...

hi,

Can you send a binary SMS OR port directed SMS to emulator.


I have written below code in my main app manifest and main code:







public class SMSReceiver extends BroadcastReceiver {


static final String ACTION =
"android.intent.action.DATA_SMS_RECEIVED";
@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
System.out.println("onReceiveDataSMS");
if (arg1.getAction().equals(ACTION))
{
XYZ;
}
}


------------------------
and following code in my test app:


android.telephony.SmsManager sm =
android.telephony.SmsManager.getDefault();
short port = 16001;
sm.sendDataMessage("5554", null, port, "Hello".getBytes(),
null, null);

thanks
sam


I am running my test app on emulator @5556 and main app @5554. But I
am unable to receive the binary sms to 5554 emulator