काम करने के तरीके में बदलाव: Android 16 या उसके बाद के वर्शन को टारगेट करने वाले ऐप्लिकेशन

पिछले रिलीज़ की तरह ही, Android 16 में भी बर्ताव से जुड़े ऐसे बदलाव शामिल हैं जिनसे आपके ऐप्लिकेशन पर असर पड़ सकता है. बर्ताव से जुड़े ये बदलाव, सिर्फ़ उन ऐप्लिकेशन पर लागू होते हैं जो Android 16 या इसके बाद के वर्शन को टारगेट करते हैं. अगर आपका ऐप्लिकेशन Android 16 या उसके बाद के वर्शन को टारगेट कर रहा है, तो आपको अपने ऐप्लिकेशन में बदलाव करना चाहिए, ताकि यह इन बदलावों के साथ काम कर सके.

Android 16 पर काम करने वाले सभी ऐप्लिकेशन पर असर डालने वाले बदलावों की सूची भी देखना न भूलें. भले ही, आपके ऐप्लिकेशन का targetSdkVersion कुछ भी हो.

उपयोगकर्ता अनुभव और सिस्टम यूज़र इंटरफ़ेस (यूआई)

Android 16 (एपीआई लेवल 36) में ये बदलाव किए गए हैं, ताकि उपयोगकर्ता को बेहतर और आसान अनुभव मिल सके.

एज-टू-एज ऑप्ट-आउट की सुविधा बंद होने वाली है

Android 15 (एपीआई लेवल 35) को टारगेट करने वाले ऐप्लिकेशन के लिए, Android 15 में एज-टू-एज डिसप्ले की सुविधा लागू की गई है. हालांकि, आपका ऐप्लिकेशन R.attr#windowOptOutEdgeToEdgeEnforcement को true पर सेट करके, इस सुविधा से ऑप्ट-आउट कर सकता है. Android 16 (एपीआई लेवल 36) को टारगेट करने वाले ऐप्लिकेशन के लिए, R.attr#windowOptOutEdgeToEdgeEnforcement एट्रिब्यूट का इस्तेमाल नहीं किया जा सकता. साथ ही, इसे बंद कर दिया गया है. इसलिए, आपका ऐप्लिकेशन एज-टू-एज डिसप्ले की सुविधा से ऑप्ट-आउट नहीं कर सकता.

  • अगर आपका ऐप्लिकेशन Android 16 (एपीआई लेवल 36) को टारगेट करता है और वह Android 15 डिवाइस पर चल रहा है, तो R.attr#windowOptOutEdgeToEdgeEnforcement काम करता रहेगा.
  • अगर आपका ऐप्लिकेशन Android 16 (एपीआई लेवल 36) को टारगेट करता है और वह Android 16 डिवाइस पर चल रहा है, तो R.attr#windowOptOutEdgeToEdgeEnforcement बंद हो जाता है.

Android 16 Beta 3 में टेस्ट करने के लिए, पक्का करें कि आपका ऐप्लिकेशन किनारे-किनारे तक दिखने की सुविधा के साथ काम करता हो. साथ ही, R.attr#windowOptOutEdgeToEdgeEnforcement का इस्तेमाल न करें, ताकि आपका ऐप्लिकेशन Android 15 डिवाइस पर भी किनारे-किनारे तक दिखने की सुविधा के साथ काम कर सके. पूरे स्क्रीन पर दिखने वाले आइटम के लिए, लिखें और व्यू से जुड़े दिशा-निर्देश देखें.

अनुमानित रीडायरेक्ट की सुविधा के लिए, माइग्रेट करना या ऑप्ट-आउट करना ज़रूरी है

For apps targeting Android 16 (API level 36) or higher and running on an Android 16 or higher device, the predictive back system animations (back-to-home, cross-task, and cross-activity) are enabled by default. Additionally, onBackPressed is not called and KeyEvent.KEYCODE_BACK is not dispatched anymore.

If your app intercepts the back event and you haven't migrated to predictive back yet, update your app to use supported back navigation APIs. or temporarily opt out by setting the android:enableOnBackInvokedCallback attribute to false in the <application> or <activity> tag of your app's AndroidManifest.xml file.

The predictive back-to-home animation.
The predictive cross-activity animation.
The predictive cross-task animation.

Elegant फ़ॉन्ट एपीआई बंद कर दिए गए हैं

Apps targeting Android 15 (API level 35) have the elegantTextHeight TextView attribute set to true by default, replacing the compact font with one that is much more readable. You could override this by setting the elegantTextHeight attribute to false.

Android 16 deprecates the elegantTextHeight attribute, and the attribute will be ignored once your app targets Android 16. The "UI fonts" controlled by these APIs are being discontinued, so you should adapt any layouts to ensure consistent and future proof text rendering in Arabic, Lao, Myanmar, Tamil, Gujarati, Kannada, Malayalam, Odia, Telugu or Thai.

elegantTextHeight behavior for apps targeting Android 14 (API level 34) and lower, or for apps targeting Android 15 (API level 35) that overrode the default by setting the elegantTextHeight attribute to false.
elegantTextHeight behavior for apps targeting Android 16, or for apps targeting Android 15 (API level 35) that didn't override the default by setting the elegantTextHeight attribute to false.

मुख्य फ़ंक्शन

Android 16 (एपीआई लेवल 36) में ये बदलाव किए गए हैं. इनसे Android सिस्टम की मुख्य सुविधाओं में बदलाव होता है या उन्हें बेहतर बनाया जाता है.

तय दर पर काम शेड्यूल करने की सुविधा को ऑप्टिमाइज़ करना

Prior to targeting Android 16, when scheduleAtFixedRate missed a task execution due to being outside a valid process lifecycle, all missed executions immediately execute when the app returns to a valid lifecycle.

When targeting Android 16, at most one missed execution of scheduleAtFixedRate is immediately executed when the app returns to a valid lifecycle. This behavior change is expected to improve app performance. Test this behavior in your app to check if your app is impacted. You can also test by using the app compatibility framework and enabling the STPE_SKIP_MULTIPLE_MISSED_PERIODIC_TASKS compat flag.

डिवाइस के नाप या आकार

Android 16 (एपीआई लेवल 36) में, बड़ी स्क्रीन वाले डिवाइसों पर ऐप्लिकेशन के दिखने के तरीके में ये बदलाव किए गए हैं.

अडैप्टिव लेआउट

Android ऐप्लिकेशन अब कई तरह के डिवाइसों (जैसे, फ़ोन, टैबलेट, फ़ोल्ड किए जा सकने वाले डिवाइस, डेस्कटॉप, कार, और टीवी) और बड़ी स्क्रीन पर विंडो मोड (जैसे, स्प्लिट स्क्रीन और डेस्कटॉप विंडो) पर काम करते हैं. इसलिए, डेवलपर को ऐसे Android ऐप्लिकेशन बनाने चाहिए जो किसी भी स्क्रीन और विंडो साइज़ के हिसाब से काम करते हों. भले ही, डिवाइस का ओरिएंटेशन कुछ भी हो. आज के समय में, कई डिवाइसों पर काम करने वाले ऐप्लिकेशन के लिए, ओरिएंटेशन और साइज़ बदलने की सुविधा पर पाबंदी लगाना बहुत सीमित है.

ओरिएंटेशन, साइज़ बदलने, और आसपेक्ट रेशियो से जुड़ी पाबंदियों को अनदेखा करना

Android 16 (एपीआई लेवल 36) को टारगेट करने वाले ऐप्लिकेशन के लिए, Android 16 में बदलाव किए गए हैं. इन बदलावों से, सिस्टम के ओरिएंटेशन, साइज़ में बदलाव करने की सुविधा, और आसपेक्ट रेशियो की पाबंदियों को मैनेज करने के तरीके में बदलाव हुआ है. जिन डिसप्ले की सबसे छोटी चौड़ाई 600dp से ज़्यादा है उन पर ये पाबंदियां अब लागू नहीं होतीं. ऐप्लिकेशन, पूरी डिसप्ले विंडो को भी भर देते हैं. भले ही, आसपेक्ट रेशियो या उपयोगकर्ता के पसंदीदा ओरिएंटेशन का कोई फ़र्क़ न पड़े. साथ ही, पिलरबॉक्सिंग का इस्तेमाल नहीं किया जाता.

इस बदलाव से, प्लैटफ़ॉर्म के काम करने का नया स्टैंडर्ड तरीका लागू होगा. Android एक ऐसे मॉडल पर काम कर रहा है जिसमें ऐप्लिकेशन, अलग-अलग ओरिएंटेशन, डिसप्ले साइज़, और आसपेक्ट रेशियो के हिसाब से काम कर सकें. तय किए गए ओरिएंटेशन या सीमित साइज़ में बदलाव करने जैसी पाबंदियों की वजह से, ऐप्लिकेशन को अलग-अलग डिवाइसों पर इस्तेमाल करना मुश्किल हो जाता है. इसलिए, हमारा सुझाव है कि उपयोगकर्ताओं को बेहतरीन अनुभव देने के लिए, अपने ऐप्लिकेशन को अडैप्टिव बनाएं.

ऐप्लिकेशन के साथ काम करने वाले डिवाइसों के फ़्रेमवर्क का इस्तेमाल करके और UNIVERSAL_RESIZABLE_BY_DEFAULT के साथ काम करने की सुविधा वाले फ़्लैग को चालू करके भी, इस व्यवहार की जांच की जा सकती है.

आम तौर पर होने वाले बदलाव

ओरिएंटेशन, साइज़ में बदलाव करने, और आसपेक्ट रेशियो की पाबंदियों को अनदेखा करने से, कुछ डिवाइसों पर आपके ऐप्लिकेशन के यूज़र इंटरफ़ेस (यूआई) पर असर पड़ सकता है. खास तौर पर, उन एलिमेंट पर असर पड़ सकता है जिन्हें पोर्ट्रेट ओरिएंटेशन में लॉक किए गए छोटे लेआउट के लिए डिज़ाइन किया गया था. उदाहरण के लिए, स्ट्रेच किए गए लेआउट और ऑफ़-स्क्रीन ऐनिमेशन और कॉम्पोनेंट जैसी समस्याएं. आसपेक्ट रेशियो या ओरिएंटेशन के बारे में कोई भी अनुमान लगाने से, आपके ऐप्लिकेशन में विज़ुअल से जुड़ी समस्याएं हो सकती हैं. इन समस्याओं से बचने और अपने ऐप्लिकेशन के अडैप्टिव व्यवहार को बेहतर बनाने के बारे में ज़्यादा जानें.

डिवाइस के रोटेशन की अनुमति देने पर, गतिविधि को फिर से बनाने की संख्या बढ़ जाती है. अगर उपयोगकर्ता की स्थिति को ठीक से सेव नहीं किया जाता है, तो इससे उपयोगकर्ता की स्थिति खो सकती है. यूज़र इंटरफ़ेस की स्थिति सेव करना लेख में, यूज़र इंटरफ़ेस की स्थिति को सही तरीके से सेव करने का तरीका जानें.

लागू करने से जुड़ी जानकारी

बड़ी स्क्रीन वाले डिवाइसों पर, फ़ुलस्क्रीन और मल्टी-विंडो मोड में, मेनिफ़ेस्ट के इन एट्रिब्यूट और रनटाइम एपीआई को अनदेखा किया जाता है:

screenOrientation, setRequestedOrientation(), और getRequestedOrientation() के लिए, इन वैल्यू को अनदेखा किया जाता है:

  • portrait
  • reversePortrait
  • sensorPortrait
  • userPortrait
  • landscape
  • reverseLandscape
  • sensorLandscape
  • userLandscape

डिसप्ले के साइज़ में बदलाव करने के मामले में, android:resizeableActivity="false", android:minAspectRatio, और android:maxAspectRatio का कोई असर नहीं पड़ता.

Android 16 (एपीआई लेवल 36) को टारगेट करने वाले ऐप्लिकेशन के लिए, बड़ी स्क्रीन पर ऐप्लिकेशन के ओरिएंटेशन, साइज़ बदलने, और आसपेक्ट रेशियो से जुड़ी पाबंदियां डिफ़ॉल्ट रूप से लागू नहीं होती हैं. हालांकि, जो ऐप्लिकेशन पूरी तरह से तैयार नहीं हैं वे ऑप्ट आउट करके, कुछ समय के लिए इस व्यवहार को बदल सकते हैं. इससे, ऐप्लिकेशन को काम करने के लिए बनाए गए पुराने मोड में रखा जाता है.

अपवाद

Android 16 में, ओरिएंटेशन, साइज़ बदलने, और आसपेक्ट रेशियो से जुड़ी पाबंदियां इन स्थितियों में लागू नहीं होतीं:

  • गेम (android:appCategory फ़्लैग के आधार पर)
  • डिवाइस के आसपेक्ट रेशियो की सेटिंग में जाकर, उपयोगकर्ताओं ने ऐप्लिकेशन के डिफ़ॉल्ट तरीके के लिए साफ़ तौर पर ऑप्ट-इन किया हो
  • sw600dp से छोटी स्क्रीन

कुछ समय के लिए ऑप्ट आउट करना

किसी खास गतिविधि से ऑप्ट आउट करने के लिए, PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY मेनिफ़ेस्ट प्रॉपर्टी का एलान करें:

<activity ...>
  <property android:name="android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY" android:value="true" />
  ...
</activity>

अगर आपके ऐप्लिकेशन के कई हिस्से Android 16 के लिए तैयार नहीं हैं, तो ऐप्लिकेशन लेवल पर उसी प्रॉपर्टी को लागू करके, पूरी तरह से ऑप्ट आउट किया जा सकता है:

<application ...>
  <property android:name="android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY" android:value="true" />
</application>

सेहत और फ़िटनेस

Android 16 (एपीआई लेवल 36) में, सेहत और फ़िटनेस से जुड़े डेटा से जुड़े ये बदलाव किए गए हैं.

सेहत और फ़िटनेस से जुड़ी अनुमतियां

Android 16 (एपीआई लेवल 36) या उसके बाद के वर्शन को टारगेट करने वाले ऐप्लिकेशन के लिए, BODY_SENSORS अनुमतियां, android.permissions.health में मौजूद ज़्यादा सटीक अनुमतियों में बदल रही हैं. इनका इस्तेमाल Health Connect भी करता है. पहले जिस एपीआई को BODY_SENSORS या BODY_SENSORS_BACKGROUND की ज़रूरत थी उसे अब उससे जुड़ी android.permissions.health अनुमति की ज़रूरत होगी. इसका असर इन डेटा टाइप, एपीआई, और फ़ोरग्राउंड सेवा के टाइप पर पड़ता है:

अगर आपका ऐप्लिकेशन इन एपीआई का इस्तेमाल करता है, तो अब उसे ज़्यादा जानकारी वाली अनुमतियों का अनुरोध करना चाहिए:

  • ऐप्लिकेशन इस्तेमाल करने के दौरान, दिल की धड़कन, SpO2 या त्वचा के तापमान को मॉनिटर करने के लिए: android.permissions.health में जाकर, ज़्यादा जानकारी वाली अनुमति का अनुरोध करें. जैसे, BODY_SENSORS के बजाय READ_HEART_RATE.
  • बैकग्राउंड में सेंसर का ऐक्सेस पाने के लिए: BODY_SENSORS_BACKGROUND के बजाय, READ_HEALTH_DATA_IN_BACKGROUND का अनुरोध करें.

ये अनुमतियां, Health Connect से डेटा पढ़ने के ऐक्सेस की सुरक्षा करने वाली अनुमतियों जैसी ही हैं. यह Android का डेटास्टोर है, जिसमें सेहत, फ़िटनेस, और सेहत से जुड़ी जानकारी का डेटा सेव होता है.

मोबाइल ऐप्लिकेशन पर मौजूद हैं

READ_HEART_RATE और अन्य ज़्यादा जानकारी वाली अनुमतियों का इस्तेमाल करने के लिए माइग्रेट करने वाले मोबाइल ऐप्लिकेशन को, ऐप्लिकेशन की निजता नीति दिखाने के लिए किसी गतिविधि का एलान भी करना होगा. यह वही ज़रूरी शर्त है जो Health Connect के लिए भी है.

कनेक्टिविटी

Android 16 (एपीआई लेवल 36) में, ब्लूटूथ स्टैक में ये बदलाव किए गए हैं, ताकि सहायक डिवाइसों के साथ कनेक्टिविटी को बेहतर बनाया जा सके.

बॉन्ड के खत्म होने और एन्क्रिप्शन में बदलावों को मैनेज करने के लिए नए इंटेंट

बॉन्ड के खोने की बेहतर तरीके से निगरानी करने के लिए, Android 16 में दो नए इंटेंट भी जोड़े गए हैं. इनसे ऐप्लिकेशन को बॉन्ड के खोने और एन्क्रिप्शन में हुए बदलावों के बारे में ज़्यादा जानकारी मिलती है.

Android 16 को टारगेट करने वाले ऐप्लिकेशन अब ये काम कर सकते हैं:

  • रिमोट बॉन्ड के गायब होने का पता चलने पर, ACTION_KEY_MISSING इंटेंट पाएं. इससे, उपयोगकर्ता को ज़्यादा जानकारी देने और ज़रूरी कार्रवाई करने में मदद मिलती है.
  • लिंक के एन्क्रिप्शन की स्थिति में बदलाव होने पर, ACTION_ENCRYPTION_CHANGE इंटेंट पाना. इसमें एन्क्रिप्शन की स्थिति में बदलाव, एन्क्रिप्शन एल्गोरिदम में बदलाव, और एन्क्रिप्शन कुंजी के साइज़ में बदलाव शामिल है. अगर बाद में ACTION_ENCRYPTION_CHANGE इंटेंट मिलने पर लिंक को एन्क्रिप्ट कर दिया जाता है, तो ऐप्लिकेशन को यह मान लेना चाहिए कि बॉन्ड फिर से चालू हो गया है.

अगर आपका ऐप्लिकेशन फ़िलहाल बॉन्ड के खत्म होने की समस्या को मैनेज करने के लिए, कस्टम तरीके का इस्तेमाल करता है, तो बॉन्ड के खत्म होने की जानकारी देने वाले इवेंट का पता लगाने और उन्हें मैनेज करने के लिए, नए इंटेंट ACTION_KEY_MISSING पर माइग्रेट करें. हमारा सुझाव है कि आपका ऐप्लिकेशन, डिवाइस को अनलिंक करने और फिर से जोड़ने की प्रोसेस शुरू करने से पहले, उपयोगकर्ता को यह पुष्टि करने के लिए गाइड करे कि रिमोट डिवाइस, स्मार्टवॉच की रेंज में है या नहीं.

इसके अलावा, अगर ACTION_KEY_MISSING इंटेंट मिलने के बाद कोई डिवाइस डिसकनेक्ट हो जाता है, तो आपके ऐप्लिकेशन को उस डिवाइस से फिर से कनेक्ट करने में सावधानी बरतनी चाहिए. ऐसा इसलिए, क्योंकि हो सकता है कि वह डिवाइस अब सिस्टम से बंधा न हो.

सुरक्षा

Android 16 (एपीआई लेवल 36) में सुरक्षा से जुड़े ये बदलाव शामिल हैं.

MediaStore के वर्शन को लॉक करना

Android 16 या इसके बाद के वर्शन को टारगेट करने वाले ऐप्लिकेशन के लिए, MediaStore#getVersion() अब हर ऐप्लिकेशन के लिए यूनीक होगा. इससे वर्शन स्ट्रिंग से पहचान करने वाली प्रॉपर्टी हट जाती हैं, ताकि फ़िंगरप्रिंटिंग तकनीकों के गलत इस्तेमाल को रोका जा सके. ऐप्लिकेशन को इस वर्शन के फ़ॉर्मैट के बारे में कोई अनुमान नहीं लगाना चाहिए. इस एपीआई का इस्तेमाल करते समय, ऐप्लिकेशन को पहले से ही वर्शन में होने वाले बदलावों को मैनेज करना चाहिए. ज़्यादातर मामलों में, उन्हें अपने मौजूदा व्यवहार में बदलाव करने की ज़रूरत नहीं पड़ती. हालांकि, ऐसा तब तक नहीं होगा, जब तक डेवलपर ने इस एपीआई के दायरे से बाहर की अतिरिक्त जानकारी का अनुमान लगाने की कोशिश नहीं की है.

निजता

Android 16 (एपीआई लेवल 36) में निजता से जुड़े ये बदलाव शामिल हैं.

लोकल नेटवर्क की अनुमति

Devices on the LAN can be accessed by any app that has the INTERNET permission. This makes it easy for apps to connect to local devices but it also has privacy implications such as forming a fingerprint of the user, and being a proxy for location.

The Local Network Protections project aims to protect the user's privacy by gating access to the local network behind a new runtime permission.

Release plan

This change will be deployed between two releases, 25Q2 and TBD respectively. It is imperative that developers follow this guidance for 25Q2 and share feedback because these protections will be enforced at a later Android release. Moreover, they will need to update scenarios which depend on implicit local network access by using the following guidance and prepare for user rejection and revocation of the new permission.

Impact

At the current stage, LNP is an opt-in feature which means only the apps that opt in will be affected. The goal of the opt-in phase is for app developers to understand which parts of their app depend on implicit local network access such that they can prepare to permission guard them for the next release.

Apps will be affected if they access the user's local network using:

  • Direct or library use of raw sockets on local network addresses (e.g. mDNS or SSDP service discovery protocol)
  • Use of framework level classes that access the local network (e.g. NsdManager)

Traffic to and from a local network address requires local network access permission. The following table lists some common cases:

App Low Level Network Operation Local Network Permission Required
Making an outgoing TCP connection yes
Accepting incoming TCP connections yes
Sending a UDP unicast, multicast, broadcast yes
Receiving an incoming UDP unicast, multicast, broadcast yes

These restrictions are implemented deep in the networking stack, and thus they apply to all networking APIs. This includes sockets created in native or managed code, networking libraries like Cronet and OkHttp, and any APIs implemented on top of those. Trying to resolve services on the local network (i.e. those with a .local suffix) will require local network permission.

Exceptions to the rules above:

  • If a device's DNS server is on a local network, traffic to or from it (at port 53) doesn't require local network access permission.
  • Applications using Output Switcher as their in-app picker won't need local network permissions (more guidance to come in 2025Q4).

Developer Guidance (Opt-in)

To opt into local network restrictions, do the following:

  1. Flash the device to a build with 25Q2 Beta 3 or later.
  2. Install the app to be tested.
  3. Toggle the Appcompat flag in adb:

    adb shell am compat enable RESTRICT_LOCAL_NETWORK <package_name>
    
  4. Reboot The device

Now your app's access to the local network is restricted and any attempt to access the local network will lead to socket errors. If you are using APIs that perform local network operations outside of your app process (ex: NsdManager), they won't be impacted during the opt-in phase.

To restore access, you must grant your app permission to NEARBY_WIFI_DEVICES.

  1. Ensure the app declares the NEARBY_WIFI_DEVICES permission in its manifest.
  2. Go to Settings > Apps > [Application Name] > Permissions > Nearby devices > Allow.

Now your app's access to the local network should be restored and all your scenarios should work as they did prior to opting the app in.

Once enforcement for local network protection begins, here is how the app network traffic will be impacted.

Permission Outbound LAN Request Outbound/Inbound Internet Request Inbound LAN Request
Granted Works Works Works
Not Granted Fails Works Fails

Use the following command to toggle-off the App-Compat flag

adb shell am compat disable RESTRICT_LOCAL_NETWORK <package_name>

Errors

Errors arising from these restrictions will be returned to the calling socket whenever it invokes send or a send variant to a local network address.

Example errors:

sendto failed: EPERM (Operation not permitted)

sendto failed: ECONNABORTED (Operation not permitted)

Local Network Definition

A local network in this project refers to an IP network that utilizes a broadcast-capable network interface, such as Wi-Fi or Ethernet, but excludes cellular (WWAN) or VPN connections.

The following are considered local networks:

IPv4:

  • 169.254.0.0/16 // Link Local
  • 100.64.0.0/10 // CGNAT
  • 10.0.0.0/8 // RFC1918
  • 172.16.0.0/12 // RFC1918
  • 192.168.0.0/16 // RFC1918

IPv6:

  • Link-local
  • Directly-connected routes
  • Stub networks like Thread
  • Multiple-subnets (TBD)

Additionally, both multicast addresses (224.0.0.0/4, ff00::/8) and the IPv4 broadcast address (255.255.255.255) are classified as local network addresses.