Android 15 के लिए, फ़ोरग्राउंड सेवा के टाइप में हुए बदलाव
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
हम Android 15 में, फ़ोरग्राउंड सेवा के टाइप में ये बदलाव कर रहे हैं.
- मेनिफ़ेस्ट में जाकर, फ़ोरग्राउंड सेवा के टाइप की जानकारी दें. इसके लिए,
android:foregroundServiceType
mediaProcessing
- अपने मेनिफ़ेस्ट में एलान करने की अनुमति
FOREGROUND_SERVICE_MEDIA_PROCESSING
startForeground()
को पास करने के लिए कॉन्स्टेंट
FOREGROUND_SERVICE_TYPE_MEDIA_PROCESSING
- रनटाइम की ज़रूरी शर्तें
- कोई नहीं
- ब्यौरा
मीडिया ऐसेट पर ज़्यादा समय लेने वाले काम करने की सेवा. जैसे, मीडिया को अलग-अलग फ़ॉर्मैट में बदलना. सिस्टम इस सेवा को सीमित समय के लिए चलाने की अनुमति देता है. आम तौर पर, यह समयसीमा हर 24 घंटे में 6 घंटे की होती है. (यह सीमा, ऐप्लिकेशन की सभी mediaProcessing
फ़ोरग्राउंड सेवाओं के लिए लागू होती है.)
आपके ऐप्लिकेशन को मीडिया प्रोसेसिंग सेवा को मैन्युअल तरीके से बंद करना चाहिए, अगर:
टाइम आउट की अवधि खत्म होने पर, सिस्टम सेवा के Service.onTimeout(int, int)
तरीके को कॉल करता है. इस समय, सेवा के पास Service.stopSelf()
को कॉल करने के लिए कुछ सेकंड होते हैं. अगर सेवा Service.stopSelf()
को कॉल नहीं करती है, तो इस गड़बड़ी के मैसेज के साथ ANR होगा: "<fgs_type> की फ़ोरग्राउंड सेवा, तय समयसीमा में नहीं रुकी: <component_name>".
ध्यान दें: Service.onTimeout(int, int)
, Android 14 या इससे पहले के वर्शन पर उपलब्ध नहीं है. इन वर्शन वाले डिवाइसों पर, अगर मीडिया प्रोसेस करने वाली सेवा टाइम आउट की अवधि तक पहुंच जाती है, तो सिस्टम तुरंत ऐप्लिकेशन को कैश मेमोरी में सेव कर देता है. इसलिए, आपके ऐप्लिकेशन को टाइम आउट की सूचना मिलने का इंतज़ार नहीं करना चाहिए.
इसके बजाय, उसे फ़ोरग्राउंड सेवा को बंद कर देना चाहिए या ज़रूरत पड़ने पर उसे बैकग्राउंड सेवा में बदल देना चाहिए.
कैमरा
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
ब्रॉडकास्ट रिसीवर पर, फ़ोरग्राउंड सेवाएं लॉन्च करने से जुड़ी पाबंदियां देखें.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया."],[],[],null,["# Changes to foreground service types for Android 15\n\nWe are making the following changes to foreground service types with Android\n15.\n\n### Media processing\n\nForeground service type to declare in manifest under\n`android:foregroundServiceType`\n: `mediaProcessing`\n\nPermission to declare in your manifest\n: `FOREGROUND_SERVICE_MEDIA_PROCESSING`\n\nConstant to pass to `startForeground()`\n: `FOREGROUND_SERVICE_TYPE_MEDIA_PROCESSING`\n\nRuntime prerequisites\n: None\n\nDescription\n\n: Service for performing time-consuming operations on media assets, like\n converting media to different formats. The system allows this service a limited\n time to run; under normal circumstances, this time limit would be 6 hours out of\n every 24. (This limit is shared by all of an app's `mediaProcessing` foreground\n services.)\n\n: Your app should manually stop the media processing service in the following\n scenario:\n\n - When the transcoding operation finishes or reaches a failure state, have the service call [`Service.stopForeground()`](/reference/android/app/Service#stopForeground(int)) and [`Service.stopSelf()`](/reference/android/app/Service#stopSelf()) to stop the service completely.\n\n: If the timeout period is reached, the system calls the service's\n [`Service.onTimeout(int, int)`](/reference/android/app/Service#onTimeout(int,%20int)) method. At this\n time, the service has a few\n seconds to call [`Service.stopSelf()`](/reference/android/app/Service#stopSelf()). If the service does not call\n `Service.stopSelf()`, an ANR will occur with this error message: \"A\n foreground service of *\\\u003cfgs_type\\\u003e* did not stop within its\n timeout: *\\\u003ccomponent_name\\\u003e*\".\n\n **Note** : `Service.onTimeout(int, int)` is not available on Android 14\n or lower. On devices running those versions, if a media processing\n service reaches the timeout period, the system immediately caches the app.\n For this reason, your app shouldn't wait to get a timeout notification.\n Instead, it should terminate the foreground service or change it to a\n background service as soon as appropriate.\n\n### Camera\n\nApps that target Android 15 or higher are not allowed to launch a\ncamera foreground service from a `BOOT_COMPLETED` broadcast receiver.\nFor more information, see\n[Restrictions on `BOOT_COMPLETED` broadcast receivers launching foreground\nservices](/about/versions/15/behavior-changes-15#fgs-boot-completed).\n\n### Data sync\n\nApps that target Android 15 or higher are not allowed to launch a\ndata sync foreground service from a `BOOT_COMPLETED` broadcast receiver.\nFor more information, see\n[Restrictions on `BOOT_COMPLETED` broadcast receivers launching foreground\nservices](/about/versions/15/behavior-changes-15#fgs-boot-completed).\n\n### Media playback\n\nApps that target Android 15 or higher are not allowed to launch a\nmedia playback foreground service from a `BOOT_COMPLETED` broadcast receiver.\nFor more information, see\n[Restrictions on `BOOT_COMPLETED` broadcast receivers launching foreground\nservices](/about/versions/15/behavior-changes-15#fgs-boot-completed).\n\n### Media projection\n\nApps that target Android 15 or higher are not allowed to launch a\nmedia projection foreground service from a `BOOT_COMPLETED` broadcast receiver.\nFor more information, see\n[Restrictions on `BOOT_COMPLETED` broadcast receivers launching foreground\nservices](/about/versions/15/behavior-changes-15#fgs-boot-completed).\n\n### Microphone\n\nApps that target Android 14 (API level 34) or higher are not allowed to launch a\nmicrophone foreground service from a `BOOT_COMPLETED` broadcast receiver.\nFor more information, see\n[Restrictions on `BOOT_COMPLETED` broadcast receivers launching foreground\nservices](/about/versions/15/behavior-changes-15#fgs-boot-completed).\n\n### Phone call\n\nApps that target Android 15 or higher are not allowed to launch a\nphone call foreground service from a `BOOT_COMPLETED` broadcast receiver.\nFor more information, see\n[Restrictions on `BOOT_COMPLETED` broadcast receivers launching foreground\nservices](/about/versions/15/behavior-changes-15#fgs-boot-completed)."]]