SUMMARY

This chapter described the various ways to communicate with the outside world. You first learned how to send and receive SMS messages. You then learned how to send e-mail messages from within your Android application. The chapter ended with lessons on using the HTTP protocol to download data from a web server.

EXERCISES

1. Name the two ways in which you can send SMS messages in your Android application.

2. Name the permissions you need to declare in your AndroidManifest.xml file for sending and receiving SMS messages.

3. How do you notify an activity from a BroadcastReceiver?

4. Name the permissions you need to declare in your AndroidManifest.xml file for an HTTP connection.

Answers to the Exercises can be found in Appendix C.

• WHAT YOU LEARNED IN THIS CHAPTER

TOPIC KEY CONCEPTS
Programmatically sending SMS messages Use the SmsManager class.
Getting feedback on messages sent Use two PendingIntent objects in the sendTextMessage() method.
Sending SMS messages using Intent Set the intent type to “vnd.android-dir/mms-sms.”
Receiving SMS messages Implement a BroadcastReceiver and set it in the AndroidManifest.xml file.
Sending e-mail using Intent Set the intent type to “message/rfc822.”
Establishing an HTTP connection Use the HttpURLConnection class.
Accessing Web services Use the Document, DocumentBuilderFactory, and DocumentBuilder classes to parse the XML result returned by the Web service.

Get Beginning Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.