Google is committed to advancing racial equity for Black communities. See how.

Foreground service types in Android 11

Change details

Change Name: CAMERA_MICROPHONE_CAPABILITY_CHANGE_ID

Change ID: 136219221

How to toggle

As you test your app's compatibility with Android 11, you can toggle this change on or off using the following ADB commands:

adb shell am compat enable (136219221|CAMERA_MICROPHONE_CAPABILITY_CHANGE_ID) PACKAGE_NAME
adb shell am compat disable (136219221|CAMERA_MICROPHONE_CAPABILITY_CHANGE_ID) PACKAGE_NAME

For more information about the compatibility framework and toggling changes, see Test your app's compatibility with Android 11.

Since Android 9, apps are limited to access the camera and microphone in the foreground only. Android 11 further protects users by introducing changes to how foreground services can access data related to the camera and microphone. If your app targets Android 11 and accesses these types of data in a foreground service, you need to include the new camera and microphone types in the foregroundServiceType attribute of that foreground service's declaration.

Example using location and camera

If a foreground service in your app needs to access data related to the device's location and camera, declare the service as shown in the following snippet:

<manifest>
    ...
    <service ... android:foregroundServiceType="location|camera" />
</manifest>

Example using location, camera, and microphone

If a foreground service needs to access location, the camera, and the microphone, declare the service as shown in the following snippet:

<manifest>
    ...
    <service ...
        android:foregroundServiceType="location|camera|microphone" />
</manifest>