1

I have created an android application. Now I want to send SMS through it to a real mobile number... Can somebody please help me with it. The information provided on the internet is to send message between two emulators. But I want to send sms on a real mobile number... Please help me out with it.

mkj
  • 2,761
  • 5
  • 24
  • 28
thedarkpassenger
  • 7,158
  • 3
  • 37
  • 61

3 Answers3

1

The emulator its not a real phone, don't have a number or sim card so it can't send or receive sms from external devices. From cmd telnet you can use sms send phonenumber

EDIT :

 private SmsMessage[] getMessagesFromIntent(Intent intent) {
    SmsMessage msgs[] = null;
    Bundle bundle = intent.getExtras();
    try {
        Object pdus[] = (Object[]) bundle.get("pdus");
        msgs = new SmsMessage[pdus.length];
        for (int n = 0; n < pdus.length; n++) {
            byte[] byteData = (byte[]) pdus[n];
            msgs[n] = SmsMessage.createFromPdu(byteData);
        }
    }
    catch (Exception e) {
        Logger.getDefault().error("Fail to create an incoming SMS from pdus", e);
    }
    return msgs;
}
113408
  • 3,364
  • 6
  • 27
  • 54
1

I think you couldn't send SMS from Emulator to real device because it doesn't have any number. I have added the code below which will be helpful to send sms from real device.

    PendingIntent pi = PendingIntent.getActivity(this, 0,
            new Intent(this, RoadMoveActivity.class), 0);    
    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage(sms_phonenumber, null, sms_message, pi, null);

Its worked for me

vinothp
  • 9,939
  • 19
  • 61
  • 103
0

Refer this Question for how to set up an email account in your android emulator How can i configure gmail in Android emulator? and then use the following code to send a email,

  Intent email = new Intent(Intent.ACTION_SEND);
    email.putExtra(Intent.EXTRA_EMAIL, new String[]{"youremail@yahoo.com"});          
    email.putExtra(Intent.EXTRA_SUBJECT, "subject");
    email.putExtra(Intent.EXTRA_TEXT, "message");
    email.setType("message/rfc822");
    startActivity(Intent.createChooser(email, "Choose an Email client :"));
Community
  • 1
  • 1
Aerrow
  • 12,086
  • 10
  • 56
  • 90