Receiving and Broadcasting Intents Android

Intents serve yet another purpose. You can broadcast an Intent object (via a call to broadcastIntent()) 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 ACTION_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.


Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Android Topics