Creating Android Apps that Send and Receive SMS Messages and Send Email

Beginning Android Application DevelopmentOnce your basic Android application is up and running, the next interesting thing you can add to it is the capability to communicate with the outside world. You may want your application to send an SMS message to another phone when an event happens (such as when you reach a particular geographical location), or you may wish to access a Web service that provides certain services (such as currency exchange, weather, etc.).

In this chapter, you learn how to send and receive SMS messages programmatically from within your Android application.

You will also learn how to use the HTTP protocol to talk to web servers so that you can download text and binary data. The last part of this chapter shows you how to parse XML files to extract the relevant parts of an XML file — a technique that is useful if you are accessing Web services.

Download Creating Android Apps that Send and Receive SMS Messages and Send Email

This article is chapter 8 "Messaging and Networking" of the book Beginning Android Application Development by Wei-Meng Lee  (ISBN: 978-1-1180-8729-9, Wrox, 2011, Copyright John Wiley & Sons, Inc.) Also available in DRM-free PDF ebook.




4 responses to “Creating Android Apps that Send and Receive SMS Messages and Send Email”

  1. Anonymous says:

    this article is very good and helpful for begainer android developer

  2. Abbaty48 says:

    wow this is very good especially for beginer like me

  3. sima says:

    So cool, thank you for this it was very helpful for me, but I need to ask something about the recieved sms, actually I want that the application detect only the sms of a specific number, is that possible ?

    • Ishanka Ranatunga says:

      Yes, you can. You can use the IF condition in the loop. here is the example:

      ​for (int i=0; i<msgs.length; i++){
      ​​​​​​​​​​​​​​​​msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
      if( msgs[i].getOriginatingAddress().equals("00000000"){
      ​​​​​​​​​​​​​​​​str += “SMS from “ + msgs[i].getOriginatingAddress();
      ​​​​​​​​​​​​​​​​str += “ :”;
      ​​​​​​​​​​​​​​​​str += msgs[i].getMessageBody().toString();
      ​​​​​​​​​​​​​​​​str += “\n”;}

      enter any number you want in the if condition.
      Happy Coding.. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *