We are making the following changes to foreground service types with Android 15.
處理中的媒體項目
- Foreground service type to declare in manifest under
android:foregroundServiceTypemediaProcessing- 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
mediaProcessingforeground services.)Your app should manually stop the media processing service in the following scenario:
- When the transcoding operation finishes or reaches a failure state, have the
service call
Service.stopForeground()andService.stopSelf()to stop the service completely.
- When the transcoding operation finishes or reaches a failure state, have the
service call
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 callService.stopSelf(). If the service does not callService.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 廣播接收器啟動前景服務」。
同步處理資料
指定 Android 15 以上版本為目標版本的應用程式,不得透過 BOOT_COMPLETED 廣播接收器啟動資料同步前景服務。詳情請參閱「限制 BOOT_COMPLETED 廣播接收器啟動前景服務」。
媒體播放
指定 Android 15 以上版本為目標版本的應用程式,不得透過 BOOT_COMPLETED 廣播接收器啟動媒體播放前景服務。詳情請參閱「限制 BOOT_COMPLETED 廣播接收器啟動前景服務」。
媒體投影
指定 Android 15 以上版本為目標版本的應用程式,不得透過 BOOT_COMPLETED 廣播接收器啟動媒體投影前景服務。詳情請參閱「限制 BOOT_COMPLETED 廣播接收器啟動前景服務」。
麥克風
指定 Android 14 (API 級別 34) 以上版本為目標版本的應用程式,不得透過 BOOT_COMPLETED 廣播接收器啟動麥克風前景服務。詳情請參閱「限制 BOOT_COMPLETED 廣播接收器啟動前景服務」。
語音通話
指定 Android 15 以上版本為目標版本的應用程式,不得透過 BOOT_COMPLETED 廣播接收器啟動電話通話前景服務。詳情請參閱「限制 BOOT_COMPLETED 廣播接收器啟動前景服務」。