Android 15 के लिए, फ़ोरग्राउंड सेवा के टाइप में हुए बदलाव

We are making the following changes to foreground service types with 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 ब्रॉडकास्ट रिसीवर पर, फ़ोरग्राउंड सेवाएं लॉन्च करने से जुड़ी पाबंदियां देखें.

डेटा सिंक करना

Android 15 या इसके बाद के वर्शन को टारगेट करने वाले ऐप्लिकेशन, BOOT_COMPLETED ब्रॉडकास्ट रिसीवर से डेटा सिंक करने वाली फ़ोरग्राउंड सेवा लॉन्च नहीं कर सकते. ज़्यादा जानकारी के लिए, BOOT_COMPLETED ब्रॉडकास्ट रिसीवर पर, फ़ोरग्राउंड सेवाएं लॉन्च करने से जुड़ी पाबंदियां देखें.

मीडिया प्लेबैक

Android 15 या इसके बाद के वर्शन को टारगेट करने वाले ऐप्लिकेशन, BOOT_COMPLETED ब्रॉडकास्ट रिसीवर से मीडिया चलाने की फ़ोरग्राउंड सेवा लॉन्च नहीं कर सकते. ज़्यादा जानकारी के लिए, BOOT_COMPLETED ब्रॉडकास्ट रिसीवर पर, फ़ोरग्राउंड सेवाएं लॉन्च करने से जुड़ी पाबंदियां देखें.

मीडिया प्रोजेक्शन

Android 15 या इसके बाद के वर्शन को टारगेट करने वाले ऐप्लिकेशन, BOOT_COMPLETED ब्रॉडकास्ट रिसीवर से मीडिया प्रोजेक्शन फ़ोरग्राउंड सेवा लॉन्च नहीं कर सकते. ज़्यादा जानकारी के लिए, BOOT_COMPLETED ब्रॉडकास्ट रिसीवर पर, फ़ोरग्राउंड सेवाएं लॉन्च करने से जुड़ी पाबंदियां देखें.

माइक्रोफ़ोन

Android 14 (एपीआई लेवल 34) या उसके बाद के वर्शन को टारगेट करने वाले ऐप्लिकेशन, BOOT_COMPLETED ब्रॉडकास्ट रिसीवर से माइक्रोफ़ोन फ़ोरग्राउंड सेवा लॉन्च नहीं कर सकते. ज़्यादा जानकारी के लिए, BOOT_COMPLETED ब्रॉडकास्ट रिसीवर पर, फ़ोरग्राउंड सेवाएं लॉन्च करने से जुड़ी पाबंदियां देखें.

फ़ोन कॉल

Android 15 या इसके बाद के वर्शन को टारगेट करने वाले ऐप्लिकेशन, BOOT_COMPLETED ब्रॉडकास्ट रिसीवर से फ़ोन कॉल फ़ोरग्राउंड सेवा लॉन्च नहीं कर सकते. ज़्यादा जानकारी के लिए, BOOT_COMPLETED ब्रॉडकास्ट रिसीवर पर, फ़ोरग्राउंड सेवाएं लॉन्च करने से जुड़ी पाबंदियां देखें.