Junior — Middle
How does the registration of components in an Android application occur?
sobes.tech AI
Answer from AI
In an Android application, components (Activity, Service, BroadcastReceiver, ContentProvider) are registered in the manifest file AndroidManifest.xml. This file specifies the class name of the component and its properties, such as the intents it can handle.
Example of registering an Activity:
<application>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Components can also be registered dynamically in code (for example, BroadcastReceiver via registerReceiver), but the main registration occurs through the manifest.