पिछली रिलीज़ की तरह ही, 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 में टेस्ट करने के लिए, पक्का करें कि आपका ऐप्लिकेशन किनारे से किनारे तक स्क्रीन पर दिखने की सुविधा के साथ काम करता हो. साथ ही, R.attr#windowOptOutEdgeToEdgeEnforcement
का इस्तेमाल बंद कर दें, ताकि आपका ऐप्लिकेशन Android 15 वाले डिवाइस पर भी किनारे से किनारे तक स्क्रीन पर दिखने की सुविधा के साथ काम कर सके. स्क्रीन के किनारों तक दिखने वाले आइटम के लिए,
लिखें और व्यू से जुड़े दिशा-निर्देश देखें.
अनुमानित रीडायरेक्ट की सुविधा के लिए, माइग्रेट करना या ऑप्ट-आउट करना ज़रूरी है
Android 16 (एपीआई लेवल 36) या उसके बाद के वर्शन को टारगेट करने वाले और Android 16 या उसके बाद के वर्शन वाले डिवाइसों पर चलने वाले ऐप्लिकेशन के लिए, अनुमानित बैक सिस्टम ऐनिमेशन (होम स्क्रीन पर वापस जाना, एक टास्क से दूसरे टास्क पर जाना, और एक गतिविधि से दूसरी गतिविधि पर जाना) डिफ़ॉल्ट रूप से चालू होते हैं.
इसके अलावा, onBackPressed
को कॉल नहीं किया जाता और अब KeyEvent.KEYCODE_BACK
को डिस्पैच नहीं किया जाता.
अगर आपका ऐप्लिकेशन, 'वापस जाएं' इवेंट को इंटरसेप्ट करता है और आपने अब तक अनुमानित 'वापस जाएं' सुविधा पर माइग्रेट नहीं किया है, तो अपने ऐप्लिकेशन को अपडेट करें, ताकि वह काम करने वाले 'वापस जाएं' नेविगेशन एपीआई का इस्तेमाल कर सके. इसके अलावा, अपने ऐप्लिकेशन की AndroidManifest.xml
फ़ाइल के <application>
या <activity>
टैग में, android:enableOnBackInvokedCallback
एट्रिब्यूट को false
पर सेट करके, कुछ समय के लिए ऑप्ट आउट करें.
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 (API level 36), 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
resizableActivity
minAspectRatio
maxAspectRatio
setRequestedOrientation()
getRequestedOrientation()
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 भी इनका इस्तेमाल करता है. Android 16 के बाद, किसी भी एपीआई को BODY_SENSORS
या BODY_SENSORS_BACKGROUND
की ज़रूरत पड़ने पर, अब उससे जुड़ी android.permissions.health
अनुमति की ज़रूरत होगी. इसका असर इन डेटा टाइप, एपीआई, और फ़ोरग्राउंड सेवा के टाइप पर पड़ता है:
- Wear OS पर Health Services से
HEART_RATE_BPM
- Android Sensor Manager से
Sensor.TYPE_HEART_RATE
- Wear OS पर
ProtoLayout
सेheartRateAccuracy
औरheartRateBpm
FOREGROUND_SERVICE_TYPE_HEALTH
, जहांBODY_SENSORS
के बजाय, संबंधितandroid.permission.health
अनुमति की ज़रूरत है
अगर आपका ऐप्लिकेशन इन एपीआई का इस्तेमाल करता है, तो उसे ज़्यादा जानकारी वाली अनुमतियों का अनुरोध करना चाहिए:
- इस्तेमाल के दौरान, दिल की धड़कन, SpO2 या त्वचा के तापमान की निगरानी करने के लिए:
android.permissions.health
में जाकर, ज़्यादा जानकारी वाली अनुमति का अनुरोध करें. जैसे,BODY_SENSORS
के बजायREAD_HEART_RATE
. - बैकग्राउंड में सेंसर का ऐक्सेस पाने के लिए:
BODY_SENSORS_BACKGROUND
के बजाय,READ_HEALTH_DATA_IN_BACKGROUND
का अनुरोध करें.
ये अनुमतियां, Health Connect से डेटा पढ़ने की अनुमतियों जैसी ही हैं. Health Connect, सेहत, फ़िटनेस, और तंदुरुस्ती से जुड़े डेटा के लिए Android का डेटास्टोर है.
मोबाइल ऐप्लिकेशन पर मौजूद हैं
READ_HEART_RATE
और अन्य ज़्यादा जानकारी वाली अनुमतियों का इस्तेमाल करने के लिए माइग्रेट करने वाले मोबाइल ऐप्लिकेशन को, ऐप्लिकेशन की निजता नीति दिखाने के लिए किसी गतिविधि का एलान भी करना होगा. यह वही ज़रूरी शर्त है जो Health Connect के लिए भी है.
कनेक्टिविटी
Android 16 (एपीआई लेवल 36) में, ब्लूटूथ स्टैक में ये बदलाव किए गए हैं, ताकि सहायक डिवाइसों के साथ कनेक्टिविटी को बेहतर बनाया जा सके.
बॉन्ड के खत्म होने और एन्क्रिप्शन में बदलावों को मैनेज करने के लिए नए इंटेंट
As part of the Improved bond loss handling, Android 16 also introduces 2 new intents to provide apps with greater awareness of bond loss and encryption changes.
Apps targeting Android 16 can now:
- Receive an
ACTION_KEY_MISSING
intent when remote bond loss is detected, allowing them to provide more informative user feedback and take appropriate actions. - Receive an
ACTION_ENCRYPTION_CHANGE
intent whenever encryption status of the link changes. This includes encryption status change, encryption algorithm change, and encryption key size change. Apps must consider the bond restored if the link is successfully encrypted upon receivingACTION_ENCRYPTION_CHANGE
intent later.
Adapting to varying OEM implementations
While Android 16 introduces these new intents, their implementation and broadcasting can vary across different device manufacturers (OEMs). To ensure your app provides a consistent and reliable experience across all devices, developers should design their bond loss handling to gracefully adapt to these potential variations.
We recommend the following app behaviors:
If the
ACTION_KEY_MISSING
intent is broadcast:The ACL (Asynchronous Connection-Less) link will be disconnected by the system, but the bond information for the device will be retained (as described here).
Your app should use this intent as the primary signal for bond loss detection and guiding the user to confirm the remote device is in range before initiating device forgetting or re-pairing.
If a device disconnects after
ACTION_KEY_MISSING
is received, your app should be cautious about reconnecting, as the device may no longer be bonded with the system.If the
ACTION_KEY_MISSING
intent is NOT broadcast:The ACL link will remain connected, and the bond information for the device will be removed by the system, same to behavior in Android 15.
In this scenario, your app should continue its existing bond loss handling mechanisms as in previous Android releases, to detect and manage bond loss events.
ब्लूटूथ बॉन्ड हटाने का नया तरीका
All apps targeting Android 16 are now able to unpair bluetooth devices using a
public API in CompanionDeviceManager
. If a companion device is
being managed as a CDM association, then the app can trigger
bluetooth bond removal by using the new removeBond(int)
API
on the associated device. The app can monitor the bond state changes by
listening to the bluetooth device broadcast event
ACTION_BOND_STATE_CHANGED
.
सुरक्षा
Android 16 (एपीआई लेवल 36) में सुरक्षा से जुड़े ये बदलाव शामिल हैं.
MediaStore के वर्शन को लॉक करना
Android 16 या इसके बाद के वर्शन को टारगेट करने वाले ऐप्लिकेशन के लिए, MediaStore#getVersion()
अब हर ऐप्लिकेशन के लिए यूनीक होगा. इससे वर्शन स्ट्रिंग से पहचान करने वाली प्रॉपर्टी हट जाती हैं, ताकि फ़िंगरप्रिंटिंग तकनीकों के गलत इस्तेमाल को रोका जा सके. ऐप्लिकेशन को इस वर्शन के फ़ॉर्मैट के बारे में कोई अनुमान नहीं लगाना चाहिए. इस एपीआई का इस्तेमाल करते समय, ऐप्लिकेशन को पहले से ही वर्शन में होने वाले बदलावों को मैनेज करना चाहिए. ज़्यादातर मामलों में, उन्हें अपने मौजूदा व्यवहार में बदलाव करने की ज़रूरत नहीं पड़ती. हालांकि, ऐसा तब तक नहीं होगा, जब तक डेवलपर ने इस एपीआई के दायरे से बाहर की अतिरिक्त जानकारी का अनुमान लगाने की कोशिश नहीं की है.
सेफ़र इंटेंट
'ज़्यादा सुरक्षित इंटेंट' सुविधा, सुरक्षा से जुड़ी एक ऐसी पहल है जिसे कई चरणों में लागू किया जाता है. इसे Android के इंटेंट रिज़ॉल्यूशन मैकेनिज्म की सुरक्षा को बेहतर बनाने के लिए डिज़ाइन किया गया है. इसका मकसद, इंटेंट प्रोसेस करने के दौरान जांच जोड़कर और खास शर्तें पूरी न करने वाले इंटेंट को फ़िल्टर करके, ऐप्लिकेशन को नुकसान पहुंचाने वाली कार्रवाइयों से बचाना है.
Android 15 में, यह सुविधा भेजने वाले ऐप्लिकेशन पर फ़ोकस करती थी. अब Android 16 में, यह कंट्रोल पाने वाले ऐप्लिकेशन पर फ़ोकस करती है. इससे डेवलपर, अपने ऐप्लिकेशन मेनिफ़ेस्ट का इस्तेमाल करके, इंटेंट रिज़ॉल्यूशन के सख्त नियमों के लिए ऑप्ट-इन कर सकते हैं.
दो मुख्य बदलाव लागू किए जा रहे हैं:
एक्सप्लिसिट इंटेंट, टारगेट कॉम्पोनेंट के इंटेंट फ़िल्टर से मैच होने चाहिए: अगर कोई इंटेंट साफ़ तौर पर किसी कॉम्पोनेंट को टारगेट करता है, तो उसे उस कॉम्पोनेंट के इंटेंट फ़िल्टर से मैच करना चाहिए.
जिन इंटेंट में कोई कार्रवाई तय नहीं की गई है वे किसी भी इंटेंट फ़िल्टर से मैच नहीं कर सकते: जिन इंटेंट में कोई कार्रवाई तय नहीं की गई है उन्हें किसी भी इंटेंट फ़िल्टर से हल नहीं किया जाना चाहिए.
ये बदलाव सिर्फ़ तब लागू होते हैं, जब एक से ज़्यादा ऐप्लिकेशन शामिल हों. इनसे किसी एक ऐप्लिकेशन में इंटेंट मैनेज करने की सुविधा पर कोई असर नहीं पड़ता.
असर
ऑप्ट-इन करने का मतलब है कि डेवलपर को अपने ऐप्लिकेशन के मेनिफ़ेस्ट में साफ़ तौर पर इसे चालू करना होगा, ताकि यह लागू हो सके. इसलिए, इस सुविधा का असर सिर्फ़ उन ऐप्लिकेशन पर पड़ेगा जिनके डेवलपर:
- आपको 'सुरक्षित इंटेंट' सुविधा और इसके फ़ायदों के बारे में पता हो.
- अपने ऐप्लिकेशन में, इंटेंट मैनेज करने के सख्त तरीकों को शामिल करने का विकल्प चुनें.
ऑप्ट-इन करने का यह तरीका, मौजूदा ऐप्लिकेशन के काम न करने के जोखिम को कम करता है. ये ऐप्लिकेशन, इंटेंट रिज़ॉल्यूशन के मौजूदा तरीके पर भरोसा कर सकते हैं, जो कम सुरक्षित है.
Android 16 में शुरुआती असर सीमित हो सकता है. हालांकि, 'ज़्यादा सुरक्षित इंटेंट' इनिशिएटिव के तहत, Android के आने वाले वर्शन में ज़्यादा असर डालने के लिए रोडमैप तैयार किया गया है. हमारा प्लान है कि हम इंटेंट रिज़ॉल्यूशन को डिफ़ॉल्ट तौर पर लागू करें.
'ज़्यादा सुरक्षित इंटेंट' सुविधा से, Android नेटवर्क की सुरक्षा को बेहतर बनाया जा सकता है. इससे नुकसान पहुंचाने वाले ऐप्लिकेशन के लिए, इंटेंट रिज़ॉल्यूशन मैकेनिज्म में मौजूद जोखिम का फ़ायदा उठाना मुश्किल हो जाता है.
हालांकि, मौजूदा ऐप्लिकेशन के साथ काम करने से जुड़ी संभावित समस्याओं को हल करने के लिए, ऑप्ट-आउट और ज़रूरी एनफ़ोर्समेंट के ट्रांज़िशन को ध्यान से मैनेज करना होगा.
लागू करना
डेवलपर को अपने ऐप्लिकेशन मेनिफ़ेस्ट में intentMatchingFlags
एट्रिब्यूट का इस्तेमाल करके, इंटेंट मैचिंग की सटीक सुविधा को साफ़ तौर पर चालू करना होगा.
यहां एक उदाहरण दिया गया है, जिसमें इस सुविधा के लिए पूरे ऐप्लिकेशन के लिए ऑप्ट-इन किया गया है, लेकिन रिसीवर के लिए बंद/ऑप्ट-आउट किया गया है:
<application android:intentMatchingFlags="enforceIntentFilter">
<receiver android:name=".MyBroadcastReceiver" android:exported="true" android:intentMatchingFlags="none">
<intent-filter>
<action android:name="com.example.MY_CUSTOM_ACTION" />
</intent-filter>
<intent-filter>
<action android:name="com.example.MY_ANOTHER_CUSTOM_ACTION" />
</intent-filter>
</receiver>
</application>
इस्तेमाल किए जा सकने वाले फ़्लैग के बारे में ज़्यादा जानकारी:
फ़्लैग का नाम | ब्यौरा |
---|---|
enforceIntentFilter | आने वाले इंटेंट के लिए, ज़्यादा सख्त मैचिंग लागू करता है |
कोई नहीं | इनकमिंग इंटेंट के लिए, मैच करने के सभी खास नियमों को बंद कर देता है. एक से ज़्यादा फ़्लैग तय करने पर, "कोई नहीं" फ़्लैग को प्राथमिकता देकर, अलग-अलग वैल्यू को हल किया जाता है |
allowNullAction | मैच करने के नियमों को आसान बनाता है, ताकि बिना किसी कार्रवाई के भी इंटेंट को मैच किया जा सके. किसी खास व्यवहार को हासिल करने के लिए, इस फ़्लैग का इस्तेमाल "enforceIntentFilter" के साथ किया जाना चाहिए |
जांच करना और डीबग करना
नीति उल्लंघन ठीक करने की सुविधा चालू होने पर, अगर इंटेंट कॉलर ने इंटेंट को सही तरीके से भरा है, तो ऐप्लिकेशन ठीक से काम करने चाहिए.
हालांकि, ब्लॉक किए गए इंटेंट से, "PackageManager."
टैग के साथ "Intent does not match component's intent filter:"
और "Access blocked:"
जैसे चेतावनी वाले लॉग मैसेज ट्रिगर होंगे. इससे, किसी ऐसी संभावित समस्या का पता चलता है जिससे ऐप्लिकेशन पर असर पड़ सकता है और जिस पर ध्यान देने की ज़रूरत है.
Logcat फ़िल्टर:
tag=:PackageManager & (message:"Intent does not match component's intent filter:" | message: "Access blocked:")
निजता
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:
- Flash the device to a build with 25Q2 Beta 3 or later.
- Install the app to be tested.
Toggle the Appcompat flag in adb:
adb shell am compat enable RESTRICT_LOCAL_NETWORK <package_name>
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
.
- Ensure the app declares the
NEARBY_WIFI_DEVICES
permission in its manifest. - 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.
ऐप्लिकेशन के मालिकाना हक वाली फ़ोटो
When prompted for photo and video permissions by an app targeting SDK 36 or higher on devices running Android 16 or higher, users who choose to limit access to selected media will see any photos owned by the app pre-selected in the photo picker. Users can deselect any of these pre-selected items, which will revoke the app's access to those photos and videos.