Android Intents and Intents Filters


The topic chosen was Intent and Intent Filter are as follows,

What is an Intent?

An Intent is a messaging object you can use to request an action from another app component.

There are three fundamental use cases:
  • Starting an activity
  • Starting a service
  • Delivering a broadcast
Complete Topics to be a Professional Android Developer

The example below assumes that you are on the Photo Gallery Activity, and want to view a specific photo (which would open in its own activity). This is how the Intent associated with the click photo event is fired:


The primary information contained in an Intent is the following:

Component name - This optional field is an android ComponentName object representing either Activity, Service or BroadcastReceiver class.You can set the component name with setComponent(), setClass(), setClassName(), or with the Intent constructor.

Action - This is mandatory part of the Intent object and is a string naming the action to be performed — or, in the case of broadcast intents, the action that took place and is being reported.

Data - Adds a data specification to an intent filter. The specification can be just a data type (the mimeType attribute), just a URI, or both a data type and a URI.

Category - The category is an optional part of Intent object and it's a string containing additional information about the kind of component that should handle the intent.

Extras - Key-value pairs that carry additional information required to accomplish the requested action. Just as some actions use particular kinds of data URIs, some actions also use particular extras

Flags - These flags are optional part of Intent object and instruct the Android system how to launch an activity, and how to treat it after it's launched etc.

Types of Intents
  • Explicit Intents
  • Implicit Intents

Comments

Popular posts from this blog

Google Declared Best Android Apps Of 2017: No Place For Facebook Or Whatsapp That Make Everyone Love It

Steps for Android Studio - Environment Setup

Core Building Blocks of Android