Изменения в типах служб переднего плана для Android 15

Мы вносим следующие изменения в типы служб переднего плана в Android 15.

Обработка медиа

Foreground service type to declare in manifest under
android:foregroundServiceType
mediaProcessing
Permission to declare in your manifest
FOREGROUND_SERVICE_MEDIA_PROCESSING
Constant to pass to startForeground()
FOREGROUND_SERVICE_TYPE_MEDIA_PROCESSING
Runtime prerequisites
None
Description

Service for performing time-consuming operations on media assets, like converting media to different formats. The system allows this service a limited time to run; under normal circumstances, this time limit would be 6 hours out of every 24. (This limit is shared by all of an app's mediaProcessing foreground services.)

Your app should manually stop the media processing service in the following scenario:

If the timeout period is reached, the system calls the service's Service.onTimeout(int, int) method. At this time, the service has a few seconds to call Service.stopSelf(). If the service does not call Service.stopSelf(), an ANR will occur with this error message: "A foreground service of <fgs_type> did not stop within its timeout: <component_name>".

Note: Service.onTimeout(int, int) is not available on Android 14 or lower. On devices running those versions, if a media processing service reaches the timeout period, the system immediately caches the app. For this reason, your app shouldn't wait to get a timeout notification. Instead, it should terminate the foreground service or change it to a background service as soon as appropriate.

Камера

Приложениям, предназначенным для Android 15 или более поздней версии, не разрешено запускать службу переднего плана камеры из приемника вещания BOOT_COMPLETED . Дополнительные сведения см. в разделе Ограничения на широковещательные приемники BOOT_COMPLETED , запускающие службы переднего плана .

Синхронизация данных

Apps that target Android 15 or higher are not allowed to launch a data sync foreground service from a BOOT_COMPLETED broadcast receiver. For more information, see Restrictions on BOOT_COMPLETED broadcast receivers launching foreground services.

Воспроизведение мультимедиа

Приложениям, предназначенным для Android 15 или более поздней версии, не разрешено запускать службу приоритетного воспроизведения мультимедиа из широковещательного приемника BOOT_COMPLETED . Дополнительные сведения см. в разделе Ограничения на широковещательные приемники BOOT_COMPLETED , запускающие службы переднего плана .

Медиа-проекция

Приложениям, предназначенным для Android 15 или более поздней версии, не разрешено запускать службу переднего плана медиапроекции из приемника вещания BOOT_COMPLETED . Дополнительные сведения см. в разделе Ограничения на широковещательные приемники BOOT_COMPLETED , запускающие службы переднего плана .

Микрофон

Приложениям, предназначенным для Android 14 (уровень API 34) или выше, не разрешено запускать службу переднего плана микрофона из приемника вещания BOOT_COMPLETED . Дополнительные сведения см. в разделе Ограничения на широковещательные приемники BOOT_COMPLETED , запускающие службы переднего плана .

Телефонный звонок

Apps that target Android 15 or higher are not allowed to launch a phone call foreground service from a BOOT_COMPLETED broadcast receiver. For more information, see Restrictions on BOOT_COMPLETED broadcast receivers launching foreground services.