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.

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

摄像头

Apps that target Android 15 or higher are not allowed to launch a camera 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 广播接收器的限制

媒体播放

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

媒体投影

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

麦克风

以 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.