Sobes.tech
Junior — Middle

What is the role of the android:exported attribute in AndroidManifest.xml when defining app components?

sobes.tech AI

Answer from AI

The android:exported attribute in AndroidManifest.xml determines whether an app component (Activity, Service, BroadcastReceiver, or ContentProvider) can be accessed or interacted with from other applications.

  • If android:exported="true", the component is available externally, meaning other applications can launch this component.
  • If android:exported="false", the component is only available within the app itself.

This is important for security and access control. Starting from Android 12, it is mandatory to explicitly set this attribute for components with intent filters.

Example:

<activity android:name=".MainActivity" android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>