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

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

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

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

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

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

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

Android 16 के बीटा 2 वर्शन में टेस्ट करने के लिए, पक्का करें कि आपका ऐप्लिकेशन किनारे-किनारे तक दिखने की सुविधा के साथ काम करता हो. साथ ही, R.attr#windowOptOutEdgeToEdgeEnforcement का इस्तेमाल न करें. स्क्रीन के किनारों तक दिखने वाले कॉन्टेंट के लिए, कॉम्पोज़ और व्यू से जुड़े दिशा-निर्देश देखें. सुझाव/राय देने वाले पेज पर जाकर, हमें समस्या ट्रैकर में मौजूद समस्याओं के बारे में बताएं.

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

Android 16 या उसके बाद के वर्शन को टारगेट करने वाले और 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 overrided 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 में ये बदलाव किए गए हैं. इनसे Android सिस्टम की मुख्य सुविधाओं में बदलाव होता है या उन्हें बेहतर बनाया जाता है.

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

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

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

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

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

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

With Android apps now running on a variety of devices (such as phones, tablets, foldables, desktops, cars, and TVs) and windowing modes on large screens (such as split screen and desktop windowing), developers should build Android apps that adapt to any screen and window size, regardless of device orientation. Paradigms like restricting orientation and resizability are too restrictive in today's multidevice world.

Ignore orientation, resizability, and aspect ratio restrictions

For apps targeting Android 16, Android 16 includes changes to how the system manages orientation, resizability, and aspect ratio restrictions. On displays with smallest width >= 600dp, the restrictions no longer apply. Apps also fill the entire display window, regardless of aspect ratio or a user's preferred orientation, and pillarboxing isn't used.

This change introduces a new standard platform behavior. Android is moving toward a model where apps are expected to adapt to various orientations, display sizes, and aspect ratios. Restrictions like fixed orientation or limited resizability hinder app adaptability, so we recommend making your app adaptive to deliver the best possible user experience.

You can also test this behavior by using the [app compatibility framework][a16-kilo-14] and enabling the UNIVERSAL_RESIZABLE_BY_DEFAULT compat flag.

Common breaking changes

Ignoring orientation, resizability, and aspect ratio restrictions might impact your app's UI on some devices, especially elements that were designed for small layouts locked in portrait orientation: for example, issues like stretched layouts and off-screen animations and components. Any assumptions about aspect ratio or orientation can cause visual issues with your app. Learn more about how to avoid them and improve your app's adaptive behaviour.

Allowing device rotation results in more activity re-creation, which can result in losing user state if not properly preserved. Learn how to correctly save UI state in Save UI states.

Implementation details

The following manifest attributes and runtime APIs are ignored across large screen devices in full-screen and multi-window modes:

The following values for screenOrientation, setRequestedOrientation(), and getRequestedOrientation() are ignored:

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

Regarding display resizability, android:resizeableActivity="false", android:minAspectRatio, and android:maxAspectRatio have no effect.

For apps targeting Android 16, app orientation, resizability, and aspect ratio constraints are ignored on large screens by default, but every app that isn't fully ready can temporarily override this behavior by opting out (which results in the previous behavior of being placed in compatibility mode).

Exceptions

The Android 16 orientation, resizability, and aspect ratio restrictions don't apply in the following situations:

  • Games (based on the android:appCategory flag)
  • Users explicitly opting in to the app's default behavior in aspect ratio settings of the device
  • Screens that are smaller than sw600dp

Opt out temporarily

To opt out a specific activity, declare the PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY manifest property:

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

If too many parts of your app aren't ready for Android 16, you can opt out completely by applying the same property at the application level:

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

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

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

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

Android 16 या उसके बाद के वर्शन को टारगेट करने वाले ऐप्लिकेशन के लिए, 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 का डेटास्टोर है, जिसमें सेहत, फ़िटनेस, और सेहत से जुड़ी जानकारी का डेटा सेव होता है.