OpenSource For You

Types of intents

-

Intents are divided into two groups: a) Explicit intents: These explicitly specify the name of the target component to handle the intent; in these, the optional ‘component name’ fiHlG (aERYH) is sHW WR a SarWiFular YaluH, through the setCompone­nt() or setClass() methods. Implicit intents: These do not specify a target component, but include enough informatio­n for the system to determine which of the available components is best to run for that intent. Consider an app that lists the available restaurant­s near you. When you click a particular restaurant option, the applicatio­n has to ask another applicatio­n to display the route to that restaurant. To achieve this, it could either send an explicit intent directly to the ‘Google Maps’ applicatio­n, or send an implicit intent, which would be delivered to any applicatio­n that provides the ‘Maps’ functional­ity (e.g., Yahoo Maps).

b)

c) Sticky Broadcast: This is retained by the system even after it has been sent; this means that whenever you register a receiver for these intents, you will get a ‘cached’ copy of the intent that was recently sent. ACTION_BATTERY_ CHANGED, an intent that describes the changes in battery status, is a good example of a sticky broadcast.

Newspapers in English

Newspapers from India