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())来记录作业停止的原因。
如需了解应用的状态如何影响其可使用的资源,请参阅电源管理资源限制。 如需详细了解电池优化方面的最佳实践,请参阅有关针对任务调度 API 优化电池使用的指南。
我们还建议利用 Android 16 中引入的新 JobScheduler#getPendingJobReasonsHistory API 来了解作业未执行的原因。
测试
如需测试应用的行为,只要应用在 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
बिना किसी टास्क वाले जॉब को रोके जाने की वजह
An abandoned job occurs when the JobParameters object associated with the job
has been garbage collected, but JobService#jobFinished(JobParameters,
boolean) has not been called to signal job completion. This indicates that
the job may be running and being rescheduled without the app's awareness.
Apps that rely on JobScheduler, don't maintain a strong reference to the
JobParameters object, and timeout will now be granted the new job stop reason
STOP_REASON_TIMEOUT_ABANDONED, instead of STOP_REASON_TIMEOUT.
If there are frequent occurrences of the new abandoned stop reason, the system will take mitigation steps to reduce job frequency.
Apps should use the new stop reason to detect and reduce abandoned jobs.
If you're using WorkManager, AsyncTask, or DownloadManager, you aren't impacted because these APIs manage the job lifecycle on your app's behalf.
JobInfo#setImportantWhileForeground को पूरी तरह से बंद किया जा रहा है
The JobInfo.Builder#setImportantWhileForeground(boolean)
method indicates the importance of a job while the scheduling app is in the
foreground or when temporarily exempted from background restrictions.
This method has been deprecated since Android 12 (API level 31). Starting in Android 16, it no longer functions effectively and calling this method will be ignored.
This removal of functionality also applies to
JobInfo#isImportantWhileForeground(). Starting in Android
16, if the method is called, the method returns false.
ऑर्डर किए गए ब्रॉडकास्ट की प्राथमिकता का दायरा अब ग्लोबल नहीं है
Android ऐप्लिकेशन, ब्रॉडकास्ट रिसीवर पर प्राथमिकताएं तय कर सकते हैं. इससे, यह कंट्रोल किया जा सकता है कि रिसीवर, ब्रॉडकास्ट को किस क्रम में पाएं और प्रोसेस करें. मेनिफ़ेस्ट में बताए गए रिसीवर के लिए, ऐप्लिकेशन प्राथमिकता तय करने के लिए android:priority एट्रिब्यूट का इस्तेमाल कर सकते हैं. वहीं, कॉन्टेक्स्ट के हिसाब से रजिस्टर किए गए रिसीवर के लिए, ऐप्लिकेशन प्राथमिकता तय करने के लिए IntentFilter#setPriority() एपीआई का इस्तेमाल कर सकते हैं. जब कोई ब्रॉडकास्ट भेजा जाता है, तो सिस्टम उसे पाने वालों को उनकी प्राथमिकता के हिसाब से डिलीवर करता है. इसमें, सबसे ज़्यादा प्राथमिकता वाले व्यक्ति से लेकर सबसे कम प्राथमिकता वाले व्यक्ति तक का क्रम होता है.
Android 16 में, अलग-अलग प्रोसेस में android:priority एट्रिब्यूट या IntentFilter#setPriority() का इस्तेमाल करके, ब्रॉडकास्ट डिलीवरी के क्रम की गारंटी नहीं दी जाएगी. ब्रॉडकास्ट की प्राथमिकताएं, सभी प्रोसेस के बजाय सिर्फ़ एक ही आवेदन की प्रोसेस में लागू होंगी.
साथ ही, ब्रॉडकास्ट की प्राथमिकताएं अपने-आप इस सीमा में सीमित हो जाएंगी (SYSTEM_LOW_PRIORITY + 1,
SYSTEM_HIGH_PRIORITY - 1). सिर्फ़ सिस्टम कॉम्पोनेंट को SYSTEM_LOW_PRIORITY, SYSTEM_HIGH_PRIORITY को ब्रॉडकास्ट प्राथमिकता के तौर पर सेट करने की अनुमति होगी.
अगर आपका ऐप्लिकेशन इनमें से कोई एक काम करता है, तो उस पर असर पड़ सकता है:
- आपके ऐप्लिकेशन ने एक ही ब्रॉडकास्ट इंटेंट के साथ कई प्रोसेस का एलान किया है. साथ ही, प्राथमिकता के आधार पर उन इंटेंट को किसी खास क्रम में पाने की उम्मीद की है.
- आपके ऐप्लिकेशन की प्रोसेस, अन्य प्रोसेस के साथ इंटरैक्ट करती है. साथ ही, यह किसी खास क्रम में ब्रॉडकास्ट इंटेंट पाने की उम्मीद करती है.
अगर प्रोसेस को एक-दूसरे के साथ काम करना है, तो उन्हें अन्य चैनलों का इस्तेमाल करके कम्यूनिकेट करना चाहिए.
एआरटी में अंदरूनी बदलाव
Android 16 में, Android Runtime (ART) के नए अपडेट शामिल हैं. इनसे Android Runtime (ART) की परफ़ॉर्मेंस बेहतर होती है और Java की अन्य सुविधाओं के साथ काम करने में मदद मिलती है. Google Play के सिस्टम अपडेट की मदद से, ये सुधार Android 12 (एपीआई लेवल 31) और उसके बाद के वर्शन वाले एक अरब से ज़्यादा डिवाइसों के लिए भी उपलब्ध हैं.
ये बदलाव रिलीज़ होने के बाद, हो सकता है कि ART के इंटरनल स्ट्रक्चर पर निर्भर रहने वाली लाइब्रेरी और ऐप्लिकेशन कोड, Android 16 वाले डिवाइसों पर सही से काम न करें. साथ ही, ऐसा उन Android वर्शन पर भी हो सकता है जो Google Play के सिस्टम अपडेट के ज़रिए ART मॉड्यूल को अपडेट करते हैं.
डिवाइस के अंदर मौजूद स्ट्रक्चर (जैसे, नॉन-SDK इंटरफ़ेस) पर भरोसा करने से, काम करने से जुड़ी समस्याएं हमेशा हो सकती हैं. हालांकि, यह ज़रूरी है कि आप ऐसे कोड (या कोड वाली लाइब्रेरी) पर भरोसा न करें जो डिवाइस के अंदर मौजूद ART स्ट्रक्चर का इस्तेमाल करता हो. ऐसा इसलिए, क्योंकि ART में होने वाले बदलाव, डिवाइस पर चल रहे प्लैटफ़ॉर्म के वर्शन से जुड़े नहीं होते. साथ ही, ये बदलाव Google Play के सिस्टम अपडेट के ज़रिए एक अरब से ज़्यादा डिवाइसों पर लागू होते हैं.
सभी डेवलपर को यह देखना चाहिए कि Android 16 पर अपने ऐप्लिकेशन की पूरी तरह से जांच करने पर, उन पर असर पड़ा है या नहीं. इसके अलावा, जानी-पहचानी समस्याओं की सूची देखें. इससे आपको पता चलेगा कि आपका ऐप्लिकेशन, उन लाइब्रेरी पर निर्भर है या नहीं जिनकी पहचान हमने की है और जो इंटरनल ART स्ट्रक्चर पर निर्भर हैं. अगर आपके ऐप्लिकेशन कोड या लाइब्रेरी डिपेंडेंसी पर असर पड़ा है, तो जब भी हो सके सार्वजनिक एपीआई के विकल्प खोजें. साथ ही, नए इस्तेमाल के उदाहरणों के लिए सार्वजनिक एपीआई का अनुरोध करें. इसके लिए, हमारे समस्या ट्रैकर में सुविधा का अनुरोध करें.
16 केबी वाले पेज साइज़ के साथ काम करने वाला मोड
Android 15 introduced support for 16 KB memory pages to optimize performance of the platform. Android 16 adds a compatibility mode, allowing some apps built for 4 KB memory pages to run on a device configured for 16 KB memory pages.
When your app is running on a device with Android 16 or higher, if Android
detects that your app has 4 KB aligned memory pages, it automatically uses
compatibility mode and display a notification dialog to the user. Setting the
android:pageSizeCompat property in the AndroidManifest.xml to enable the
backwards compatibility mode will prevent the display of the dialog when your
app launches. To use the android:pageSizeCompat property, compile your app
using the Android 16 SDK.
For best performance, reliability, and stability, your app should still be 16 KB aligned. Check out our recent blog post on updating your apps to support 16 KB memory pages for more details.
उपयोगकर्ता अनुभव और सिस्टम यूज़र इंटरफ़ेस (यूआई)
Android 16 (एपीआई लेवल 36) में ये बदलाव शामिल हैं. इनका मकसद, उपयोगकर्ताओं को ज़्यादा बेहतर और आसान अनुभव देना है.
परेशान करने वाली सुलभता सूचनाओं को बंद करना
Android 16 废弃了无障碍功能通告,其特征是使用 announceForAccessibility 或调度 TYPE_ANNOUNCEMENT 无障碍功能事件。这可能会给 TalkBack 和 Android 屏幕阅读器用户带来不一致的用户体验,而替代方案可以更好地满足各种 Android 辅助技术的用户需求。
替代方案示例:
- 对于窗口更改等重大界面更改,请使用
Activity.setTitle(CharSequence)和setAccessibilityPaneTitle(java.lang.CharSequence)。在 Compose 中,使用Modifier.semantics { paneTitle = "paneTitle" } - 如需向用户告知关键界面的更改,请使用
setAccessibilityLiveRegion(int)。在 Compose 中,请使用Modifier.semantics { liveRegion = LiveRegionMode.[Polite|Assertive]}。应谨慎使用这些事件,因为它们可能会在每次更新视图时生成通知。 - 如需向用户发送错误通知,请发送类型为
AccessibilityEvent#CONTENT_CHANGE_TYPE_ERROR的AccessibilityEvent并设置AccessibilityNodeInfo#setError(CharSequence),或使用TextView#setError(CharSequence)。
已废弃的 announceForAccessibility API 的参考文档中包含有关建议替代方案的更多详细信息。
तीन बटन वाले नेविगेशन की सुविधा
Android 16 为已正确迁移到预测性返回的应用的三按钮导航栏引入了预测性返回支持。长按返回按钮会启动预测性返回动画,让您预览返回滑动手势会打开的界面。
此行为适用于系统中支持预测性返回动画的所有区域,包括系统动画(返回主屏幕、跨任务和跨 activity)。
थीम वाले ऐप्लिकेशन के आइकॉन अपने-आप जनरेट होने की सुविधा
Android 16 QPR 2 से, Android अपने-आप ऐप्लिकेशन के आइकॉन को थीम के हिसाब से बदल देगा, ताकि होम स्क्रीन पर एक जैसा अनुभव मिले. ऐसा तब होता है, जब कोई ऐप्लिकेशन थीम वाला आइकॉन नहीं देता. ऐप्लिकेशन, थीम वाले ऐप्लिकेशन के आइकॉन के डिज़ाइन को कंट्रोल कर सकते हैं. इसके लिए, वे अडैप्टिव आइकॉन में मोनोक्रोम लेयर शामिल करते हैं. साथ ही, Android Studio में झलक देख सकते हैं कि उनका ऐप्लिकेशन आइकॉन कैसा दिखेगा.
डिवाइस के नाप या आकार
Android 16 (एपीआई लेवल 36) में, ऐप्लिकेशन के लिए ये बदलाव शामिल हैं. ये बदलाव तब लागू होते हैं, जब वर्चुअल डिवाइस के मालिक, ऐप्लिकेशन को डिसप्ले पर प्रोजेक्ट करते हैं.
वर्चुअल डिवाइस के मालिक के लिए ओवरराइड
वर्चुअल डिवाइस का मालिक, भरोसेमंद या खास ऐप्लिकेशन होता है. यह वर्चुअल डिवाइस बनाता है और उसे मैनेज करता है. वर्चुअल डिवाइस के मालिक, वर्चुअल डिवाइस पर ऐप्लिकेशन चलाते हैं. इसके बाद, वे ऐप्लिकेशन को किसी रिमोट डिवाइस के डिसप्ले पर प्रोजेक्ट करते हैं. जैसे, पर्सनल कंप्यूटर, वर्चुअल रिएलिटी डिवाइस या कार में सूचना और मनोरंजन की सुविधा देने वाला डिवाइस. वर्चुअल डिवाइस का मालिक, किसी लोकल डिवाइस का इस्तेमाल कर रहा हो, जैसे कि मोबाइल फ़ोन.
हर ऐप्लिकेशन के लिए सेटिंग में बदलाव करना
Android 16 (एपीआई लेवल 36) पर चलने वाले डिवाइसों पर, वर्चुअल डिवाइस के मालिक, मैनेज किए जा रहे चुनिंदा वर्चुअल डिवाइसों पर ऐप्लिकेशन की सेटिंग बदल सकते हैं. उदाहरण के लिए, ऐप्लिकेशन के लेआउट को बेहतर बनाने के लिए, वर्चुअल डिवाइस का मालिक किसी बाहरी डिसप्ले पर ऐप्लिकेशन प्रोजेक्ट करते समय, ओरिएंटेशन, आसपेक्ट रेशियो (लंबाई-चौड़ाई का अनुपात), और साइज़ बदलने से जुड़ी पाबंदियों को अनदेखा कर सकता है.
नुकसान पहुंचा सकने वाले आम बदलाव
Android 16 के काम करने के तरीके से, कार के डिसप्ले या Chromebook जैसी बड़ी स्क्रीन वाले डिवाइसों पर आपके ऐप्लिकेशन के यूज़र इंटरफ़ेस (यूआई) पर असर पड़ सकता है. खास तौर पर, पोर्ट्रेट ओरिएंटेशन में छोटी स्क्रीन के लिए डिज़ाइन किए गए लेआउट पर असर पड़ सकता है. अपने ऐप्लिकेशन को सभी डिवाइसों के हिसाब से अडैप्टिव बनाने का तरीका जानने के लिए, अडैप्टिव लेआउट के बारे में जानकारी देखें.
संदर्भ
सुरक्षा
Android 16 (एपीआई लेवल 36) में ऐसे बदलाव शामिल हैं जो सिस्टम की सुरक्षा को बेहतर बनाते हैं. इससे ऐप्लिकेशन और उपयोगकर्ताओं को नुकसान पहुंचाने वाले ऐप्लिकेशन से सुरक्षित रखने में मदद मिलती है.
इंटेंट रीडायरेक्शन हमलों से बेहतर सुरक्षा
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.