ऐप्लिकेशन के व्यवहार में बदलाव: सभी ऐप्लिकेशन

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

Android 16 को टारगेट करने वाले ऐप्लिकेशन पर ही लागू होने वाले, व्यवहार में होने वाले बदलावों की सूची भी देखें.

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

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

JobScheduler के कोटा को ऑप्टिमाइज़ करना

Android 16 से, हम सामान्य और तेज़ी से टास्क पूरा करने के लिए, रनटाइम कोटे में बदलाव कर रहे हैं. यह बदलाव इन बातों के आधार पर किया जा रहा है:

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

इस बदलाव का असर, WorkManager, JobScheduler, और DownloadManager का इस्तेमाल करके शेड्यूल किए गए टास्क पर पड़ता है. किसी जॉब को क्यों रोका गया, यह डीबग करने के लिए हमारा सुझाव है कि आप यह लॉग करें कि आपकी जॉब को WorkInfo.getStopReason() को कॉल करके क्यों रोका गया (JobScheduler जॉब के लिए, JobParameters.getStopReason() को कॉल करें).

आपके ऐप्लिकेशन की स्थिति से, इस्तेमाल किए जा सकने वाले संसाधनों पर क्या असर पड़ता है, इस बारे में जानने के लिए पावर मैनेजमेंट के संसाधनों की सीमाएं देखें. बैटरी के इस्तेमाल को ऑप्टिमाइज़ करने के सबसे सही तरीकों के बारे में ज़्यादा जानने के लिए, टास्क शेड्यूल करने वाले एपीआई के लिए बैटरी के इस्तेमाल को ऑप्टिमाइज़ करने से जुड़े दिशा-निर्देश देखें.

हमारा यह भी सुझाव है कि Android 16 में लॉन्च किए गए नए JobScheduler#getPendingJobReasonsHistory एपीआई का इस्तेमाल करें. इससे आपको यह समझने में मदद मिलेगी कि कोई जॉब क्यों नहीं हुई.

टेस्ट करना

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

"सबसे ऊपर मौजूद स्थिति, नौकरी के रनटाइम कोटे का पालन करेगी" को लागू करने की सुविधा बंद करने के लिए, यह adb कमांड चलाएं:

adb shell am compat enable OVERRIDE_QUOTA_ENFORCEMENT_TO_TOP_STARTED_JOBS APP_PACKAGE_NAME

"फ़ोरग्राउंड सेवा के साथ-साथ चल रही जॉब, जॉब के रनटाइम कोटा का पालन करेंगी" को लागू करने की सुविधा बंद करने के लिए, यह adb कमांड चलाएं:

adb shell am compat enable OVERRIDE_QUOTA_ENFORCEMENT_TO_FGS_JOBS APP_PACKAGE_NAME

ऐप्लिकेशन स्टैंडबाय बकेट के कुछ व्यवहारों की जांच करने के लिए, अपने ऐप्लिकेशन के लिए ऐप्लिकेशन स्टैंडबाय बकेट सेट की जा सकती है. इसके लिए, यहां दिया गया adb कमांड इस्तेमाल करें:

adb shell am set-standby-bucket APP_PACKAGE_NAME active|working_set|frequent|rare|restricted

आपका ऐप्लिकेशन, ऐप्लिकेशन स्टैंडबाय बकेट में किस लेवल पर है, यह जानने के लिए, यहां दिए गए adb कमांड का इस्तेमाल करके, अपने ऐप्लिकेशन का ऐप्लिकेशन स्टैंडबाय बकेट पता लगाया जा सकता है:

adb shell am get-standby-bucket APP_PACKAGE_NAME

खाली जॉब को बंद करने की वजह

जब जॉब से जुड़े JobParameters ऑब्जेक्ट को गै़रबैज इकट्ठा करने की प्रोसेस के तहत हटा दिया जाता है, लेकिन जॉब पूरा होने का सिग्नल देने के लिए JobService#jobFinished(JobParameters, boolean) को कॉल नहीं किया जाता है, तो जॉब को छोड़ दिया जाता है. इससे पता चलता है कि ऐप्लिकेशन के बिना, शायद जॉब चल रहा हो और उसे फिर से शेड्यूल किया जा रहा हो.

JobScheduler पर निर्भर ऐप्लिकेशन, JobParameters ऑब्जेक्ट का सटीक रेफ़रंस नहीं रखते. साथ ही, टाइम आउट होने पर अब STOP_REASON_TIMEOUT के बजाय, STOP_REASON_TIMEOUT_ABANDONED को नौकरी के रुकने की नई वजह के तौर पर इस्तेमाल किया जाएगा.

अगर 'नया काम बंद होने की वजह' बार-बार दिखती है, तो सिस्टम, जॉब की फ़्रीक्वेंसी कम करने के लिए कदम उठाएगा.

ऐप्लिकेशन को, 'कार्रवाई रोकने की नई वजह' का इस्तेमाल करके, अधूरे रह गए टास्क का पता लगाना चाहिए और उनकी संख्या कम करनी चाहिए.

अगर आपने WorkManager, AsyncTask या DownloadManager का इस्तेमाल किया है, तो आप पर इसका कोई असर नहीं पड़ेगा. ऐसा इसलिए, क्योंकि ये एपीआई आपके ऐप्लिकेशन की ओर से जॉब लाइफ़साइकल को मैनेज करते हैं.

JobInfo#setImportantWhileForeground को पूरी तरह से बंद करना

JobInfo.Builder#setImportantWhileForeground(boolean) तरीका, शेड्यूलिंग ऐप्लिकेशन के फ़ोरग्राउंड में होने या बैकग्राउंड में काम करने से जुड़ी पाबंदियों से कुछ समय के लिए छूट मिलने पर, किसी टास्क की अहमियत दिखाता है.

Android 12 (एपीआई लेवल 31) के बाद, यह तरीका काम नहीं करता. Android 16 से, यह तरीका ठीक से काम नहीं करता. साथ ही, इस तरीके को कॉल करने पर, उसे अनदेखा कर दिया जाएगा.

यह सुविधा हटाने का फ़ैसला, JobInfo#isImportantWhileForeground() पर भी लागू होता है. Android 16 में, अगर इस तरीके को कॉल किया जाता है, तो यह false दिखाता है.

ऑर्डर किए गए ब्रॉडकास्ट की प्राथमिकता का दायरा अब ग्लोबल नहीं है

Android apps are allowed to define priorities on broadcast receivers to control the order in which the receivers receive and process the broadcast. For manifest-declared receivers, apps can use the android:priority attribute to define the priority and for context-registered receivers, apps can use the IntentFilter#setPriority() API to define the priority. When a broadcast is sent, the system delivers it to receivers in order of their priority, from highest to lowest.

In Android 16, broadcast delivery order using the android:priority attribute or IntentFilter#setPriority() across different processes will not be guaranteed. Broadcast priorities will only be respected within the same application process rather than across all processes.

Also, broadcast priorities will be automatically confined to the range (SYSTEM_LOW_PRIORITY + 1, SYSTEM_HIGH_PRIORITY - 1). Only system components will be allowed to set SYSTEM_LOW_PRIORITY, SYSTEM_HIGH_PRIORITY as broadcast priority.

Your app might be impacted if it does either of the following:

  1. Your application has declared multiple processes with the same broadcast intent, and has expectations around receiving those intents in a certain order based on the priority.
  2. Your application process interacts with other processes and has expectations around receiving a broadcast intent in a certain order.

If the processes need to coordinate with each other, they should communicate using other coordination channels.

ART में किए गए इंटरनल बदलाव

Android 16 includes the latest updates to the Android Runtime (ART) that improve the Android Runtime's (ART's) performance and provide support for additional Java features. Through Google Play System updates, these improvements are also available to over a billion devices running Android 12 (API level 31) and higher.

As these changes are released, libraries and app code that rely on internal structures of ART might not work correctly on devices running Android 16, along with earlier Android versions that update the ART module through Google Play system updates.

Relying on internal structures (such as non-SDK interfaces) can always lead to compatibility problems, but it's particularly important to avoid relying on code (or libraries containing code) that leverages internal ART structures, since ART changes aren't tied to the platform version the device is running on and they go out to over a billion devices through Google Play system updates.

All developers should check whether their app is impacted by testing their apps thoroughly on Android 16. In addition, check the known issues to see if your app depends on any libraries that we've identified that rely on internal ART structures. If you do have app code or library dependencies that are affected, seek public API alternatives whenever possible and request public APIs for new use cases by creating a feature request in our issue tracker.

16 केबी वाले पेज साइज़ के साथ कंपैटबिलिटी मोड

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

अगर आपका ऐप्लिकेशन Android 16 या उसके बाद के वर्शन वाले डिवाइस पर चल रहा है और Android को पता चलता है कि आपके ऐप्लिकेशन में 4 केबी के अलाइन किए गए मेमोरी पेज हैं, तो यह अपने-आप कंपैटबिलिटी मोड का इस्तेमाल करता है और उपयोगकर्ता को सूचना वाला डायलॉग बॉक्स दिखाता है. बैकवर्ड कम्पैटिबिलिटी मोड को चालू करने के लिए, AndroidManifest.xml में android:pageSizeCompat प्रॉपर्टी को सेट करने पर, ऐप्लिकेशन लॉन्च होने पर डायलॉग नहीं दिखेगा. android:pageSizeCompat प्रॉपर्टी का इस्तेमाल करने के लिए, Android 16 SDK का इस्तेमाल करके अपना ऐप्लिकेशन कंपाइल करें.

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

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

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

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

सुलभता से जुड़े ऐसे एलान बंद करना जो लोगों को परेशान करते हैं

Android 16 deprecates accessibility announcements, characterized by the use of announceForAccessibility or the dispatch of TYPE_ANNOUNCEMENT accessibility events. These can create inconsistent user experiences for users of TalkBack and Android's screen reader, and alternatives better serve a broader range of user needs across a variety of Android's assistive technologies.

Examples of alternatives:

The reference documentation for the deprecated announceForAccessibility API includes more details about suggested alternatives.

तीन बटन वाले नेविगेशन की सुविधा

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

यह सुविधा, सिस्टम के उन सभी हिस्सों पर लागू होती है जिनमें प्रिडिक्टिव बैक ऐनिमेशन काम करते हैं. इनमें सिस्टम ऐनिमेशन (होम स्क्रीन पर वापस जाने, एक टास्क से दूसरे टास्क पर जाने, और एक गतिविधि से दूसरी गतिविधि पर जाने) भी शामिल हैं.

तीन बटन वाले नेविगेशन मोड में, प्रिडिक्टिव बैक ऐनिमेशन.

थीम वाले ऐप्लिकेशन के आइकॉन की सुविधा अपने-आप चालू होना

Android 16 QPR 2 से, Android अपने-आप ऐप्लिकेशन के आइकॉन को थीम के हिसाब से बदल देगा, ताकि होम स्क्रीन पर एक जैसा अनुभव मिले. ऐसा तब होता है, जब कोई ऐप्लिकेशन थीम वाला आइकॉन नहीं देता. ऐप्लिकेशन, थीम वाले ऐप्लिकेशन के आइकॉन के डिज़ाइन को कंट्रोल कर सकते हैं. इसके लिए, वे अडैप्टिव आइकॉन में मोनोक्रोम लेयर शामिल करते हैं. साथ ही, Android Studio में झलक देख सकते हैं कि उनका ऐप्लिकेशन आइकॉन कैसा दिखेगा.

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

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

वर्चुअल डिवाइस के मालिक के लिए ओवरराइड

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

फ़ोन पर वर्चुअल डिवाइस का मालिक, एक वर्चुअल डिवाइस बनाता है. यह डिवाइस, ऐप्लिकेशन को रिमोट डिसप्ले पर प्रोजेक्ट करता है.

हर ऐप्लिकेशन के हिसाब से ओवरराइड

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

नुकसान पहुंचाने वाले सामान्य बदलाव

Android 16 के व्यवहार की वजह से, बड़ी स्क्रीन वाले डिवाइसों (जैसे, कार के डिसप्ले या Chromebook) पर आपके ऐप्लिकेशन के यूज़र इंटरफ़ेस (यूआई) पर असर पड़ सकता है. खास तौर पर, पोर्ट्रेट मोड में छोटी स्क्रीन के लिए डिज़ाइन किए गए लेआउट पर. अपने ऐप्लिकेशन को सभी डिवाइसों के फ़ॉर्म फ़ैक्टर के हिसाब से अडैप्टिव बनाने का तरीका जानने के लिए, अडैप्टिव लेआउट के बारे में जानकारी लेख पढ़ें.

संदर्भ

कंपैनियन ऐप्लिकेशन की स्ट्रीमिंग

सुरक्षा

Android 16 (एपीआई लेवल 36) में, ऐसे बदलाव शामिल हैं जिनसे सिस्टम की सुरक्षा बेहतर होती है. इससे, ऐप्लिकेशन और लोगों को नुकसान पहुंचाने वाले ऐप्लिकेशन से बचाया जा सकता है.

Intent रीडायरेक्शन के हमलों से सुरक्षा को बेहतर बनाना

Android 16 provides default security against general Intent redirection attacks, with minimum compatibility and developer changes required.

We are introducing by-default security hardening solutions to Intent redirection exploits. In most cases, apps that use intents normally won't experience any compatibility issues; we've gathered metrics throughout our development process to monitor which apps might experience breakages.

Intent redirection in Android occurs when an attacker can partly or fully control the contents of an intent used to launch a new component in the context of a vulnerable app, while the victim app launches an untrusted sub-level intent in an extras field of an ("top-level") Intent. This can lead to the attacker app launching private components in the context of the victim app, triggering privileged actions, or gaining URI access to sensitive data, potentially leading to data theft and arbitrary code execution.

Opt out of Intent redirection handling

Android 16 introduces a new API that allows apps to opt out of launch security protections. This might be necessary in specific cases where the default security behavior interferes with legitimate app use cases.

For applications compiling against Android 16 (API level 36) SDK or higher

You can directly use the removeLaunchSecurityProtection() method on the Intent object.

val i = intent
val iSublevel: Intent? = i.getParcelableExtra("sub_intent")
iSublevel?.removeLaunchSecurityProtection() // Opt out from hardening
iSublevel?.let { startActivity(it) }
For applications compiling against Android 15 (API level 35) or lower

While not recommended, you can use reflection to access the removeLaunchSecurityProtection() method.

val i = intent
val iSublevel: Intent? = i.getParcelableExtra("sub_intent", Intent::class.java)
try {
    val removeLaunchSecurityProtection = Intent::class.java.getDeclaredMethod("removeLaunchSecurityProtection")
    removeLaunchSecurityProtection.invoke(iSublevel)
} catch (e: Exception) {
    // Handle the exception, e.g., log it
} // Opt-out from the security hardening using reflection
iSublevel?.let { startActivity(it) }

साथी ऐप्लिकेशन को, डिस्कवरी के टाइम आउट के बारे में अब सूचना नहीं मिलेगी

Android 16 introduces a new behavior during companion device pairing flow to protect the user's location privacy from malicious apps. All companion apps running on Android 16 are no longer directly notified of discovery timeout using RESULT_DISCOVERY_TIMEOUT. Instead, the user is notified of timeout events with a visual dialog. When the user dismisses the dialog, the app is alerted of the association failure with RESULT_USER_REJECTED.

The search duration has also been extended from the original 20 seconds, and the device discovery can be stopped by the user at any point during the search. If at least one device was discovered within the first 20 seconds of starting the search, the CDM stops searching for additional devices.

कनेक्टिविटी

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

बॉन्ड लॉस को बेहतर तरीके से मैनेज करना

Starting in Android 16, the Bluetooth stack has been updated to improve security and user experience when a remote bond loss is detected. Previously, the system would automatically remove the bond and initiate a new pairing process, which could lead to unintentional re-pairing. We have seen in many instances apps not taking care of the bond loss event in a consistent way.

To unify the experience, Android 16 improved the bond loss handling to the system. If a previously bonded Bluetooth device could not be authenticated upon reconnection, the system will disconnect the link, retain local bond information, and display a system dialog informing users of the bond loss and directing them to re-pair.