Content Provider Declaration
The <provider> element declares a content provider component, which is a ContentProvider subclass that provides structured access to data managed by an application. All content providers must be declared in the manifest file; otherwise, the system will not recognize them and they will not execute. Only declare providers that belong to your own application.
Android identifies content providers using the authority string, which forms part of the content URI. For instance, to access a provider containing healthcare professional information, you might call ContentResolver.query() with a URI like:
content://com.example.healthcare.provider/medical_staff/physicians
The content:// scheme identifies this as an Android content provider URI. The authority com.example.healthcare.provider identifies the provider itself, and the system searches its list of known providers for this authority. The path segment medical_staff/physicians allows the provider to identify specific data subsets.
When defining a provider, include only the authority in the android:name attribute, without the scheme or path.
Attributes
-
android:authorities: Comma-separated list of URI authorities. Should follow Java naming conventions likecom.example.provider.inventory. At least one authority must be specified. -
android:enabled: Whether the system can instantiate the provider. Defaults totrue. Both this and the<application>element'senabledattribute must betruefor the provider to function. -
android:directBootAware: Whether the provider can run before the user unlocks the device. During direct boot, only device-protected storage is accessible. Defaults tofalse. -
android:exported: Whether other applications can access the provider. Whenfalse, only apps with the same UID or those granted temporary access viaandroid:grantUriPermissionscan interact with it. Defaults tofalsefor API level 17+ withandroid:targetSdkVersionof 17 or higher. -
android:grantUriPermissions: Allows temporary granting of access to protected data. Whentrue, any data access can be permitted. Whenfalse, access is limited to URIs specified in<grant-uri-permission>child elements. Defaults tofalse. -
android:icon,android:label: Icon and user-readable label for the provider. Falls back to application-level settings if unspecified. -
android:initOrder: Integer specifying the order in which this provider is instantiated relative to other providers in the same process. Higher values initialize earlier. -
android:multiprocess: Whentrue, each app process gets its own provider instance. Whenfalse, all processes share one instance. Defaults tofalse. Improves performance through reduced IPC overhead but increases memory footprint. -
android:name: Fully qualified class name of theContentProvidersubclass. Can use shorthand with leading dot to append to package name. -
android:permission: Single permission required for both read and write operations. Overridden byreadPermissionandwritePermissionif specified. -
android:process: Process name for the provider to run in. Names starting with:create app-private processes. -
android:readPermission,android:writePermission: Separate permissions for query and modification operations. -
android:syncable: Whether data controlled by the provider syncs with a server.
Broadcast Receiver Declaration
The <receiver> element declares a BroadcastReceiver component that can receive Intent broadcasts from the system or other applications, even when other application components are not running.
System awareness of broadcast receivers comes from two sources: manifest declaration using this element, or dynamic registration in code using Context.registerReceiver().
Performance consideration: Excessive broadcast receivers negatively impact application performance and device battery life. Consider using modern background work APIs instead.
Attributes
-
android:directBootAware: Indicates the receiver can operate during direct boot before device unlock. Only device-protected storage is accessible. Defaults tofalse. -
android:enabled: Whether the system can instantiate the receiver. Both this and the<application>element'senabledattribute must betrue. Defaults totrue. -
android:exported: Whether the receiver accepts broadcasts from external sources. Defaults tofalseif no intent filters are present (receiver used internally). Defaults totrueif at least one intent filter exists (receiver intended for external use). -
android:icon,android:label: Icon and label for the receiver. These also serve as defaults for the receiver's intent filters. Falls back to application-level settings if unspecified. -
android:name: Fully qualified class name of theBroadcastReceiversubclass. Cannot be changed after publishing unlessandroid:exported="false"is set. -
android:permission: Permission required for broadcast senders to reach this receiver. Falls back to<application>level permission if unset. -
android:process: Process name for the receiver to execute in. Leading:creates an app-private process.
Service Declaration
The <service> element declares a Service component, which lacks a visual interface and handles long-running background operations or provides communication APIs callable by other applications. All services must be declared in the manifest; undeclared services are not recognized or executed by the system.
Attributes
-
android:description: User-facing description of the service. Should reference a string resource for localization. -
android:directBootAware: Weather the service operates during direct boot. Only device-protected storage is accessible. Defaults tofalse. -
android:enabled: Whether the system can instantiate the service. Both this and the<application>element'senabledattribute must betrue. Defaults totrue. -
android:exported: Whether other application components can call or interact with the service. Whenfalse, only same-app or same-UID components can start or bind to the service. Defaults tofalsewithout intent filters,truewith intent filters. -
android:foregroundServiceType: Specifies particular use cases likelocation,mediaPlayback,dataSync,connectedDevice,mediaProjection, orphoneCall. Multiple types can be assigned. -
android:icon,android:label: Icon and display name for the service. Also serve as defaults for the service's intent filters. Falls back to application-level settings if unspecified. -
android:isolatedProcess: Whentrue, the service runs in an isolated process with no permissions, communicating only through the Service API via binding and starting. -
android:name: Fully qualified class name of theServicesubclass. Leading dot appends to package name. Cannot be changed after publishing unlessandroid:exported="false"is set. -
android:permission: Permission required for entities starting, binding to, or stopping the service. If unset, falls back to<application>level permission. -
android:process: Process name for the service. Leading:creates an app-private process, while lowercase names use global shared processes.