Intents Broadcast Receivers Adapters and the Internet

Write App Reviews

Build your own Android App Dev Empire

Get Instant Access


> An introduction to Intents

> Starting new Activities and sub-Activities using implicit and explicit Intents

> Intent filters and intent resolution

> Using linkify

> Intents, broadcast actions and Broadcast Receivers

> Using Adapters to bind data to Views

> Using the Internet in Android

> How to create and use Dialogs

At first glance the subjects of this chapter might appear to have little in common; in practice they represent the glue that binds applications and their components.

Mobile applications on most platforms run in their own sandboxes. They're isolated from each other, and have strict limitations applied to their interaction with hardware and native components. Android applications are also sandboxed but they can use Intents, Broadcast Receivers, Adapters, Content Providers, and the Internet to interact through those boundaries.

In this chapter you'll look at Intents. Intents are probably the most unique, and important, concept in Android development. You'll learnhow to use Intents to broadcast data between applications and application components, and start Activities or Services, both explicitly and using late runtime binding.

Using implicit Intents you'll learn how to request that an action be performed on a piece of data, letting Android determine which application components can best service that request.

Prepared for ASHLEE KABAT, email: [email protected] Order number: 56760408 This PDF is for the purchaser's personal use in accordance with the Wrox Terms of Service and under US copyright as stated on this book's copyright page. If you did not purchase this copy, please visit to purchase your own copy.

Broadcast Intents are used to announce events system-wide. You'll learn how to transmit these broadcasts, and receive them using Broadcast Receivers.

You'll examine Adapters and learn how to use thm to bind your presentation layer to data sources, before examining dialog boxes.

Having looked at the mechanisms for transmitting and consuming local data, you'll be introduced to Android's Internet connectivity model and some of the Java techniques for parsing Internet data feeds.

An earthquake-monitoring example will then demonstrate how to tie all these features together. The earthquake monitor will form the basis of an ongoing example that you'll improve and extend in later chapters.


Intents are used as a message-passing mechanism that works both within your application, and between applications. Intents can be used to:

> Declare your intention that an Activity or Service be started to perform an action, usually with (or on) a particular piece of data

> Broadcast that an event (or action) has occurred

> Explicitly start a particular Service or Activity

You can use Intents to support interaction among any of the application components installed on an Android device, no matter which application they're a part of. This turns your device from a platform containing a collection of independent components into a single interconnected system.

One of the most common uses for Intents is to start new Activities, either explicitly (by specifying the class to load) or implicitly (by requesting that an action be performed on a piece of data). In the latter case the action need not be performed by an Activity within the calling application.

Intents can also be used to broadcast messages across the system. Any application can register Broadcast Receivers to listen for, and react to, these broadcast Intents. This lets you create event-driven applications based on internal, system, or third-party-application events.

Android broadcasts Intents to announce system events, like changes in Internet connection status or battery charge levels. The native Android applications, such as the phone dialer and SMS manager, simply register components that listen for specific broadcast Intents—such as''incoming phone call'' or''SMS message received'' —and react accordingly.

Using Intents to propagate actions —even within the same application —is a fundamental Android design principle. It encourages the decoupling of components, to allow the seamless replacement of application elements. It also provides the basis of a simple model for extending an application's functionality.

Was this article helpful?

0 0
Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide


Post a comment