Receiving and Broadcasting Intents


Build your own Android App Dev Empire

Get Instant Access

Intents serve yet another purpose.You can broadcast an Intent object (via a call to broadcastlntent()) to the Android system, and any application interested can receive that broadcast (called a BroadcastReceiver).Your application might do both sending of and listening for Intent objects.These types of Intent objects are generally used to inform the greater system that something interesting has happened and use special Intent Action types.

For example, the Intent action action_battery_low broadcasts a warning when the battery is low. If your application is a battery-hogging Service of some kind, you might want to listen for this Broadcast and shut down your Service until the battery power is sufficient.You can register to listen for battery/charge level changes by listening for the broadcast Intent object with the Intent action ACTlON_BATTERY_CHANGED.There are also broadcast Intent objects for other interesting system events, such as SD card state changes, applications being installed or removed, and the wallpaper being changed.

Your application can also share information using the broadcast mechanism. For example, an email application might broadcast an Intent whenever a new email arrives so that other applications (such as spam or anti-virus apps) that might be interested in this type of event can react to it.


We talk more about hardware and the battery in Chapter 19, "Using Android's Optional Hardware APIs," in which you see practical examples of the use of BroadcastReceiver objects.

Was this article helpful?

0 0
Easy Software Profits

Easy Software Profits

Here's How Anyone Can Start, Build and Run their Own Successful Software Empire Without Knowing the First Thing About Programming, Scripting Or Any 'Coder' Stuff. There is no doubt about it software sells. Software has a high percieved value and it solves problems for people.  A claim that can't always be made for PDF books, Video products and the like.

Get My Free Ebook

Post a comment