Understanding Key Elements in Android Manifest Files
<action>
Syntax:
<action android:name="string" />
Contained in: <intent-filter>
Description:
Adds an action to an intent filter. An <intent-filter> must contain one or more <action> elements. Without any <action>, the filter won't accept Intent objects.
Attributes:
android:name: The action name. For standard actions defined in theIntentclass (e.g.,ACTION_MAIN), prefix with"android.intent.action."(e.g.,"android.intent.action.MAIN"). For custom actions, use your app's package name as a prefix to ensure uniqueness, like"com.example.app.CUSTOM_ACTION".
<activity-alias>
Syntax:
<activity-alias android:enabled=["true" | "false"]
android:exported=["true" | "false"]
android:icon="drawable resource"
android:label="string resource"
android:name="string"
android:permission="string"
android:targetActivity="string">
...
</activity-alias>
Contained in: <application>
May contain: <intent-filter>, <meta-data>
Description:
Defines an alias for an Activity, specified by targetActivity. The target must be in the same app and declared beforee the alias in the manifest. The alias presents the target as a separate entity with its own intent filters, which determine how Intents activate it and how the system handles the alias. For example, a alias can include "android.intent.action.MAIN" and "android.intent.category.LAUNCHER" to appear in the app launcher, even if the target Activity lacks these filters.
Attributes like enabled, exported, icon, label, name, permission, and targetActivity are specific to the alias. Other attributes inherit from the target Activity.
Key attributes:
android:enabled: Whether the system can instantiate the target via this alias. Default is"true".android:exported: Whether components from other apps can start the target through this alias. Default depends on intent filters:"false"if none,"true"if any exist.android:name: A unique name for the alias, not tied to an actual class.android:targetActivity: The name of the Activity to activate, matching an<activity>element'snameattribute.
<category>
Syntax:
<category android:name="string" />
Contained in: <intent-filter>
Description: Adds a category name to an intent filter.
Attributes:
android:name: The category name. For standard categories (e.g.,CATEGORY_LAUNCHER), use"android.intent.category.LAUNCHER". IncludeCATEGORY_DEFAULTto receive implicit Intents. Custom categories should be prefixed with your app's package name for uniqueness.
<compatible-screens>
Syntax:
<compatible-screens>
<screen android:screenSize=["small" | "normal" | "large" | "xlarge"]
android:screenDensity=["ldpi" | "mdpi" | "hdpi" | "xhdpi" | "280" | "360" | "420" | "480" | "560"] />
...
</compatible-screens>
Contained in: <manifest>
Description:
Specifies screen configurations compatible with your app. Only one <compatible-screens> element is allowed, but it can contain multiple <screen> elements, each defining a screen size-density combination. External services like Google Play use this for filtering; unlisted configurations are considered incompatible, potentially reducing your user base. Use <supports-screens> for minimum screen size declarations instead, and design for multiple screens with alternative layouts.
Child element: <screen>
android:screenSize: Required. Values:small,normal,large,xlarge.android:screenDensity: Required. Values include density constants or numeric values like"280".
Example: To support only small and normal screens across all densities, list all combinations:
<compatible-screens>
<screen android:screenSize="small" android:screenDensity="ldpi" />
<screen android:screenSize="small" android:screenDensity="mdpi" />
<!-- Additional combinations for small and normal sizes -->
</compatible-screens>
<data>
Syntax:
<data android:scheme="string"
android:host="string"
android:port="string"
android:path="string"
android:pathPattern="string"
android:pathPrefix="string"
android:mimeType="string" />
Contained in: <intent-filter>
Description:
Adds a data specification to an intent filter, which can include a MIME type, a URI, or both. URI parts are specified separately: <scheme>://<host>:<port>[<path>|<pathPrefix>|<pathPattern>]. Attributes are interdependent: without scheme, other URI attributes are ignored; without host, port and path attributes are ignored.
Multiple <data> elements within an <intent-filter> combine to offer data options.
Attributes:
android:scheme: The URI scheme (e.g.,http). Required for other URI attributes; case-sensitive in Android.android:host: The URI host (e.g.,example.com). Use*as a wildcard for subdomains (e.g.,*.example.com). Case-sensitive.android:port: The URI port, relevant only withschemeandhost.android:path,android:pathPrefix,android:pathPattern: URI path components, starting with/.pathPatternsupports wildcards like*and.*with proper escaping (e.g.,\*in XML).android:mimeType: MIME type (e.g.,image/jpeg). Use*for wildcard subtypes. Case-sensitive in Android.