# Android Manifest: Set Exported on Activities and Services

> Set the android:exported attribute on Activities, Broadcast Receivers, and Services with Intent Filters in AndroidManifest.xml, required since Android 12

**URL:** https://sentry.io/answers/setting-exported-on-activities-broadcasts-and-services/

---

## The Problem

Since Android 12, a requirement for using Activities, Broadcast Receivers, or Services with Intent Filters is to set an `exported` attribute in the Android Manifest.

Uploading an APK to the Play Store without setting an `exported` attribute might result in an error such as:

```
You uploaded an APK or Android App Bundle which has an activity, activity alias,
service, or broadcast receiver with intent filter, but without the 'android: exported'
property set. This file can't be installed on Android 12 or higher.
```

## The Solution

We'll go through examples of setting the `exported` attribute for Activities, Broadcast Receivers, and Services.

Setting the exported property to `true` allows external apps to launch the component while setting it to `false` allows only your app to launch the component.

Below is an example of an `activity` element with the `intent-filter` and the `exported` attributes set:

```xml
<activity
    android:name=".MainActivity"
    android:exported="true"
    android:theme="@style/Theme.App.Starting">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
```

Activities that implement `android.intent.category.LAUNCHER` in an `intent-filter` should set exported to `true`.

Next, we have an example of a Broadcast Receiver:

```xml
<receiver android:name=".ExampleBroadcastReceiver" android:exported="false">
    <intent-filter>
        <action android:name="EXAMPLE_BROADCAST" />
    </intent-filter>
</receiver>
```

If the receiver should listen for broadcasts from the system or external apps then set `exported` to `true`.

Finally, we have an example of a Service:

```xml
<service
    android:name=".MessagingService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>
```

As you can see, all three examples implement Intent Filters. You don't have to set the `exported` attribute if you are not using an Intent Filter.

---

*Source: [sentry.io/answers/setting-exported-on-activities-broadcasts-and-services/](https://sentry.io/answers/setting-exported-on-activities-broadcasts-and-services/)*
