Difficulty: Easy
Correct Answer: An intent filter declares the types of intents that an Android component is willing to receive, enabling the system to match and launch that component in response to specific actions, data types or categories.
Explanation:
Introduction / Context:
Intent filters are a key concept in Android that support loosely coupled communication between components. This question tests whether you understand how the system decides which activity, service or broadcast receiver should respond to a given intent. Knowing intent filters is essential for implementing features such as sharing, opening links and responding to system events.
Given Data / Assumptions:
- An Android application may define multiple activities, services and broadcast receivers.
- Intents are messages that describe actions to perform or events that have occurred.
- The Android system needs a way to know which components can handle which intents.
- The question focuses on the high level role of intent filters, not XML details.
Concept / Approach:
An intent filter is a declaration placed in the Android manifest or sometimes added at runtime to specify what kinds of intents a component can handle. It typically includes an action, such as view or send, a data specification, such as a URL pattern or MIME type, and optional categories. When an intent is broadcast or started, the Android system matches its fields against available filters and chooses one or more suitable components to launch. This mechanism enables features such as choosing between different apps to open a web link or share a photo.
Step-by-Step Solution:
Step 1: Recall that intents and intent filters work together to route messages to components.
Step 2: Look for an option that explains declaration of which intents a component is willing to receive.
Step 3: Option a states that an intent filter declares the types of intents a component can receive and that the system uses this for matching and launching.
Step 4: Confirm that this matches Android documentation and common practice.
Step 5: Select option a as the correct answer.
Verification / Alternative check:
As an alternative check, think of an activity that opens when the user taps a link with a particular domain in the browser. This activity must declare an intent filter with the appropriate view action and data pattern. When the link is tapped, the intent is matched against this filter and the activity is offered as a handler. Option a describes exactly this behaviour, confirming its correctness.
Why Other Options Are Wrong:
Option b talks only about colour schemes, which are unrelated to intents. Option c describes image compression, which belongs to build optimisation or runtime processing, not intent routing. Option d calls an intent filter a database engine, which is completely inaccurate.
Common Pitfalls:
A common pitfall is misconfiguring intent filters so that activities either do not appear when expected or unintentionally handle too many types of intents. Another issue is forgetting to provide categories or data specifications that match what the system sends. Carefully designing and testing intent filters ensures that apps integrate smoothly with the rest of the Android ecosystem.
Final Answer:
An intent filter declares the types of intents that an Android component is willing to receive, enabling the system to match and launch that component in response to specific actions, data types or categories.
Discussion & Comments