Android 15 में, पिछली रिलीज़ की तरह ही, बर्ताव से जुड़े कुछ बदलाव किए गए हैं. इनसे आपके ऐप्लिकेशन पर असर पड़ सकता है. बर्ताव से जुड़े ये बदलाव, सिर्फ़ उन ऐप्लिकेशन पर लागू होते हैं जो Android 15 या इसके बाद के वर्शन को टारगेट कर रहे हैं. अगर आपका ऐप्लिकेशन, Android 15 या इसके बाद के वर्शन को टारगेट कर रहा है, तो आपको अपने ऐप्लिकेशन में बदलाव करना चाहिए, ताकि वह इन बर्तावों के साथ सही तरीके से काम कर सके.
बर्ताव से जुड़े उन बदलावों की सूची भी देखें जो Android 15 पर चलने वाले सभी ऐप्लिकेशन पर लागू होते हैं. भले ही, आपके ऐप्लिकेशन का targetSdkVersion कुछ भी हो.
मुख्य फ़ंक्शन
Android 15 में, Android सिस्टम की कई मुख्य क्षमताओं में बदलाव किए गए हैं या उन्हें बढ़ाया गया है.
फ़ोरग्राउंड सेवाओं में बदलाव
We are making the following changes to foreground services with Android 15.
- Data sync foreground service timeout behavior
- New media processing foreground service type
- Restrictions on
BOOT_COMPLETEDbroadcast receivers launching foreground services - Restrictions on starting foreground services while an app holds the
SYSTEM_ALERT_WINDOWpermission
Data sync foreground service timeout behavior
Android 15 introduces a new timeout behavior to dataSync for apps targeting
Android 15 (API level 35) or higher. This behavior also applies to the new
mediaProcessing foreground service type.
The system permits an app's dataSync services to run for a total of 6 hours
in a 24-hour period, after which the system calls the running service's
Service.onTimeout(int, int) method (introduced in Android
15). At this time, the service has a few seconds to call
Service.stopSelf(). When Service.onTimeout() is called, the
service is no longer considered a foreground service. If the service does not
call Service.stopSelf(), the system throws an internal exception. The
exception is logged in Logcat with the following message:
Fatal Exception: android.app.RemoteServiceException: "A foreground service of
type dataSync did not stop within its timeout: [component name]"
To avoid problems with this behavior change, you can do one or more of the following:
- Have your service implement the new
Service.onTimeout(int, int)method. When your app receives the callback, make sure to callstopSelf()within a few seconds. (If you don't stop the app right away, the system generates a failure.) - Make sure your app's
dataSyncservices don't run for more than a total of 6 hours in any 24-hour period (unless the user interacts with the app, resetting the timer). - Only start
dataSyncforeground services as a result of direct user interaction; since your app is in the foreground when the service starts, your service has the full six hours after the app goes to the background. - Instead of using a
dataSyncforeground service, use an alternative API.
If your app's dataSync foreground services have run for 6 hours in the last
24, you cannot start another dataSync foreground service unless the user
has brought your app to the foreground (which resets the timer). If you try to
start another dataSync foreground service, the system throws
ForegroundServiceStartNotAllowedException
with an error message like "Time limit already exhausted for foreground service
type dataSync".
Testing
To test your app's behavior, you can enable data sync timeouts even if your app
is not targeting Android 15 (as long as the app is running on an Android 15
device). To enable timeouts, run the following adb command:
adb shell am compat enable FGS_INTRODUCE_TIME_LIMITS your-package-name
You can also adjust the timeout period, to make it easier to test how your
app behaves when the limit is reached. To set a new timeout period, run the
following adb command:
adb shell device_config put activity_manager data_sync_fgs_timeout_duration duration-in-milliseconds
New media processing foreground service type
Android 15 में, फ़ोरग्राउंड सेवा का एक नया टाइप mediaProcessing जोड़ा गया है. यह सेवा टाइप, मीडिया फ़ाइलों को ट्रांसकोड करने जैसे कामों के लिए सही है. उदाहरण के लिए, कोई मीडिया ऐप्लिकेशन किसी ऑडियो फ़ाइल को डाउनलोड कर सकता है और उसे चलाने से पहले, किसी दूसरे फ़ॉर्मैट में बदल सकता है. mediaProcessing फ़ोरग्राउंड सेवा का इस्तेमाल करके, यह पक्का किया जा सकता है कि ऐप्लिकेशन बैकग्राउंड में होने पर भी कन्वर्ज़न जारी रहे.
सिस्टम किसी ऐप्लिकेशन की mediaProcessing सेवाओं को 24 घंटों में कुल छह घंटे चलाने की अनुमति देता है. इसके बाद, सिस्टम, मौजूदा सेवा के Service.onTimeout(int, int) तरीके को कॉल करता है (Android 15 में शुरू किया गया). फ़िलहाल, Service.stopSelf() को कॉल करने के लिए सेवा को कुछ सेकंड मिलेंगे. अगर सेवा Service.stopSelf() को कॉल नहीं करती है, तो सिस्टम में कोई इंटरनल अपवाद दिखता है. अपवाद को Logcat में लॉग इन किया जाता है जिसमें यह मैसेज शामिल है:
Fatal Exception: android.app.RemoteServiceException: "A foreground service of
type mediaProcessing did not stop within its timeout: [component name]"
अपवाद से बचने के लिए, इनमें से कोई एक काम किया जा सकता है:
- अपनी सेवा में
Service.onTimeout(int, int)का नया तरीका लागू करें. जब आपके ऐप्लिकेशन को कॉलबैक मिलता है, तो कुछ सेकंड के अंदरstopSelf()को कॉल करना न भूलें. (अगर ऐप्लिकेशन को तुरंत नहीं रोका जाता, तो सिस्टम गड़बड़ी जनरेट करता है.) - पक्का करें कि आपके ऐप्लिकेशन की
mediaProcessingसेवाएं, 24 घंटे में कुल छह घंटे से ज़्यादा न चलें. ऐसा तब तक नहीं होगा, जब तक उपयोगकर्ता ऐप्लिकेशन के साथ इंटरैक्ट करके, टाइमर को रीसेट नहीं करता. - सीधे उपयोगकर्ता के साथ इंटरैक्शन होने पर ही,
mediaProcessingफ़ोरग्राउंड सेवाएं शुरू करें. सेवा शुरू होने के समय, आपका ऐप्लिकेशन फ़ोरग्राउंड में होता है. इसलिए, ऐप्लिकेशन के बैकग्राउंड में चलने के बाद, आपकी सेवा को पूरे छह घंटे तक चालू रखा जाता है. mediaProcessingफ़ोरग्राउंड सेवा का इस्तेमाल करने के बजाय, WorkManager जैसे अन्य एपीआई का इस्तेमाल करें.
अगर आपके ऐप्लिकेशन की mediaProcessing फ़ोरग्राउंड सेवाएं पिछले 24 में छह घंटों तक चली हैं, तो mediaProcessing फ़ोरग्राउंड सेवा को तब तक शुरू नहीं किया जा सकता, जब तक
उपयोगकर्ता आपके ऐप्लिकेशन को फ़ोरग्राउंड में न ले जाए (इससे टाइमर रीसेट हो जाता है). अगर कोई दूसरी mediaProcessing फ़ोरग्राउंड सेवा शुरू करने की कोशिश की जाती है, तो सिस्टम ForegroundServiceStartNotAllowedException को गड़बड़ी का मैसेज दिखाता है. जैसे, "mediaProcessing टाइप की फ़ोरग्राउंड सेवा के लिए, समयसीमा पहले ही खत्म हो चुकी है".
mediaProcessing सेवा टाइप के बारे में ज़्यादा जानकारी के लिए, Android 15 के लिए फ़ोरग्राउंड सेवा टाइप में हुए बदलाव: मीडिया प्रोसेसिंग देखें.
टेस्ट करना
अपने ऐप्लिकेशन के काम करने के तरीके की जांच करने के लिए, मीडिया प्रोसेसिंग के टाइम आउट को चालू किया जा सकता है. भले ही, आपका ऐप्लिकेशन Android 15 को टारगेट न करता हो (जब तक कि ऐप्लिकेशन, Android 15 डिवाइस पर चल रहा हो). टाइम आउट की सुविधा चालू करने के लिए, यह adb कमांड चलाएं:
adb shell am compat enable FGS_INTRODUCE_TIME_LIMITS your-package-name
टाइम आउट की अवधि में बदलाव भी किया जा सकता है. इससे यह जांचना आसान हो जाता है कि
तय सीमा पूरी होने पर, आपका ऐप्लिकेशन कैसे काम करता है. टाइम आउट की नई अवधि सेट करने के लिए, यह adb कमांड चलाएं:
adb shell device_config put activity_manager media_processing_fgs_timeout_duration duration-in-milliseconds
Restrictions on BOOT_COMPLETED broadcast receivers launching foreground services
There are new restrictions on BOOT_COMPLETED broadcast receivers launching
foreground services. BOOT_COMPLETED receivers are not allowed to launch the
following types of foreground services:
dataSynccameramediaPlaybackphoneCallmediaProjectionmicrophone(this restriction has been in place formicrophonesince Android 14)
If a BOOT_COMPLETED receiver tries to launch any of those types of foreground
services, the system throws ForegroundServiceStartNotAllowedException.
Testing
To test your app's behavior, you can enable these new restrictions even if your
app is not targeting Android 15 (as long as the app is running on an Android 15
device). Run the following adb command:
adb shell am compat enable FGS_BOOT_COMPLETED_RESTRICTIONS your-package-name
To send a BOOT_COMPLETED broadcast without restarting the device,
run the following adb command:
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED your-package-name
Restrictions on starting foreground services while an app holds the SYSTEM_ALERT_WINDOW permission
Previously, if an app held the SYSTEM_ALERT_WINDOW permission, it could launch
a foreground service even if the app was currently in the background (as
discussed in exemptions from background start restrictions).
If an app targets Android 15, this exemption is now narrower. The app now needs
to have the SYSTEM_ALERT_WINDOW permission and also have a visible overlay
window. That is, the app needs to first launch a
TYPE_APPLICATION_OVERLAY window and the window
needs to be visible before you start a foreground service.
If your app attempts to start a foreground service from the background without
meeting these new requirements (and it does not have some other exemption), the
system throws ForegroundServiceStartNotAllowedException.
If your app declares the SYSTEM_ALERT_WINDOW permission
and launches foreground services from the background, it may be affected by this
change. If your app gets a ForegroundServiceStartNotAllowedException, check
your app's order of operations and make sure your app already has an active
overlay window before it attempts to start a foreground service from the
background. You can check if your overlay window is currently visible
by calling View.getWindowVisibility(), or you
can override View.onWindowVisibilityChanged()
to get notified whenever the visibility changes.
Testing
To test your app's behavior, you can enable these new restrictions even if your
app is not targeting Android 15 (as long as the app is running on an Android 15
device). To enable these new restrictions on starting foreground services
from the background, run the following adb command:
adb shell am compat enable FGS_SAW_RESTRICTIONS your-package-name
ऐप्लिकेशन, 'डू नॉट डिस्टर्ब' मोड की ग्लोबल स्थिति में कब बदलाव कर सकते हैं, इसमें बदलाव
Android 15 (एपीआई लेवल 35) और उसके बाद के वर्शन को टारगेट करने वाले ऐप्लिकेशन, अब किसी डिवाइस पर 'परेशान न करें' (डीएनडी) मोड की ग्लोबल स्थिति या नीति को नहीं बदल सकते. ऐसा, उपयोगकर्ता की सेटिंग में बदलाव करके या डीएनडी मोड को बंद करके नहीं किया जा सकता. इसके बजाय, ऐप्लिकेशन को AutomaticZenRule का योगदान देना होगा. सिस्टम, इस योगदान को सबसे ज़्यादा पाबंदी वाली मौजूदा नीति के साथ मिलाकर, ग्लोबल नीति बनाता है. पहले जिन मौजूदा एपीआई कॉल से ग्लोबल स्टेटस (setInterruptionFilter,
setNotificationPolicy) पर असर पड़ा था उनसे, एक 'असहमति' वाला AutomaticZenRule पैरामीटर बनता है या अपडेट होता है. यह पैरामीटर, उन एपीआई कॉल के कॉल-साइकल के हिसाब से टॉगल किया जाता है.
ध्यान दें कि इस बदलाव का असर सिर्फ़ तब पड़ता है, जब ऐप्लिकेशन setInterruptionFilter(INTERRUPTION_FILTER_ALL) को कॉल कर रहा हो और उसे उम्मीद हो कि उस कॉल से, AutomaticZenRule को बंद किया जा सकेगा. AutomaticZenRule को पहले उसके मालिकों ने चालू किया था.
OpenJDK एपीआई में बदलाव
Android 15, Android की मुख्य लाइब्रेरी को रीफ़्रेश करने का काम जारी रखता है, ताकि वे OpenJDK LTS की नई रिलीज़ में मौजूद सुविधाओं के साथ काम कर सकें.
इनमें से कुछ बदलावों का असर, Android 15 (एपीआई लेवल 35) को टारगेट करने वाले ऐप्लिकेशन के साथ काम करने वाले ऐप्लिकेशन पर पड़ सकता है:
स्ट्रिंग फ़ॉर्मैट करने वाले एपीआई में बदलाव: अब
String.format()औरFormatter.format()एपीआई का इस्तेमाल करते समय, आर्ग्युमेंट इंडेक्स, फ़्लैग, चौड़ाई, और सटीक वैल्यू की पुष्टि करने के लिए ज़्यादा सख्त नियम लागू होंगे:String.format(String, Object[])String.format(Locale, String, Object[])Formatter.format(String, Object[])Formatter.format(Locale, String, Object[])
उदाहरण के लिए, जब फ़ॉर्मैट स्ट्रिंग में 0 के आर्ग्युमेंट इंडेक्स (
%0) का इस्तेमाल किया जाता है, तो यहां दी गई गड़बड़ी होती है:IllegalFormatArgumentIndexException: Illegal format argument index = 0इस मामले में, फ़ॉर्मैट स्ट्रिंग में
%1का इस्तेमाल करके, इंडेक्स आर्ग्युमेंट को 1 पर सेट किया जा सकता है.Arrays.asList(...).toArray()के कॉम्पोनेंट टाइप में बदलाव:Arrays.asList(...).toArray()का इस्तेमाल करने पर, नतीजे के तौर पर मिलने वाले ऐरे का कॉम्पोनेंट टाइप अबObjectहै. यह, अंडरलाइंग ऐरे के एलिमेंट का टाइप नहीं है. इसलिए, नीचे दिया गया कोडClassCastExceptionदिखाता है:String[] elements = (String[]) Arrays.asList("one", "two").toArray();इस मामले में, नतीजे के तौर पर मिले ऐरे में कॉम्पोनेंट टाइप के तौर पर
Stringको बनाए रखने के लिए,Collection.toArray(Object[])का इस्तेमाल किया जा सकता है:String[] elements = Arrays.asList("two", "one").toArray(new String[0]);भाषा कोड हैंडल करने के तरीके में बदलाव:
LocaleAPI का इस्तेमाल करते समय, हिब्रू, येडिश, और इंडोनेशियाई भाषा के कोड अब उनके पुराने फ़ॉर्मैट में नहीं बदले जाते. जैसे, हिब्रू:iw, येडिश:ji, और इंडोनेशियाई:in. इन भाषाओं में से किसी एक के लिए भाषा कोड तय करते समय, आईएसओ 639-1 से कोड इस्तेमाल करें. जैसे, हिब्रू:he, येडिश:yi, और इंडोनेशियाई:id.रैंडम इंट सीक्वेंस में बदलाव: https://bugs.openjdk.org/browse/JDK-8301574 में किए गए बदलावों के बाद, अब ये
Random.ints()तरीके,Random.nextInt()तरीकों से अलग संख्या वाला सीक्वेंस दिखाते हैं:आम तौर पर, इस बदलाव से ऐप्लिकेशन के काम करने के तरीके पर कोई असर नहीं पड़ता. हालांकि, आपके कोड को
Random.ints()तरीकों से जनरेट किए गए क्रम केRandom.nextInt()से मेल खाने की उम्मीद नहीं करनी चाहिए.
SequencedCollection एपीआई का इस्तेमाल करने के लिए, अपने ऐप्लिकेशन के बिल्ड कॉन्फ़िगरेशन में compileSdk को अपडेट करने के बाद, आपके ऐप्लिकेशन की कंपैटिबिलिटी पर असर पड़ सकता है. इसके लिए, आपको Android 15 (एपीआई लेवल 35) का इस्तेमाल करना होगा:
kotlin-stdlibमेंMutableList.removeFirst()औरMutableList.removeLast()एक्सटेंशन फ़ंक्शन के साथ टकरावJava में
Listटाइप को Kotlin मेंMutableListटाइप पर मैप किया जाता है.List.removeFirst()औरList.removeLast()एपीआई, Android 15 (एपीआई लेवल 35) में पेश किए गए हैं. इसलिए, Kotlin कंपाइलर फ़ंक्शन कॉल को हल करता है. उदाहरण के लिए,list.removeFirst()कोkotlin-stdlibमें एक्सटेंशन फ़ंक्शन के बजाय, नएListएपीआई के लिए स्टैटिक तौर पर हल करता है.अगर किसी ऐप्लिकेशन को
compileSdkको35पर सेट करके औरminSdkको34या इससे कम पर सेट करके फिर से कंपाइल किया जाता है और फिर उस ऐप्लिकेशन को Android 14 और इससे पहले के वर्शन पर चलाया जाता है, तो रनटाइम गड़बड़ी होती है:java.lang.NoSuchMethodError: No virtual method removeFirst()Ljava/lang/Object; in class Ljava/util/ArrayList;Android Gradle प्लगिन में मौजूद
NewApilint विकल्प, एपीआई के इन नए इस्तेमाल का पता लगा सकता है../gradlew lintMainActivity.kt:41: Error: Call requires API level 35 (current min is 34): java.util.List#removeFirst [NewApi] list.removeFirst()रनटाइम एक्सेप्शन और लिंट की गड़बड़ियों को ठीक करने के लिए, Kotlin में
removeFirst()औरremoveLast()फ़ंक्शन कॉल को क्रमशःremoveAt(0)औरremoveAt(list.lastIndex)से बदला जा सकता है. अगर Android Studio Ladybug | 2024.1.3 या इसके बाद के वर्शन का इस्तेमाल किया जा रहा है, तो इन गड़बड़ियों को तुरंत ठीक करने का विकल्प भी मिलता है.अगर लिंट विकल्प बंद कर दिया गया है, तो
@SuppressLint("NewApi")औरlintOptions { disable 'NewApi' }हटाएं.Java में अन्य तरीकों से टकराव
मौजूदा टाइप में नए तरीके जोड़े गए हैं. उदाहरण के लिए,
ListऔरDeque. ऐसा हो सकता है कि ये नई विधियां, अन्य इंटरफ़ेस और क्लास में एक ही नाम और आर्ग्युमेंट टाइप वाली विधियों के साथ काम न करें. अगर किसी तरीके के सिग्नेचर में टकराव होता है और वह काम नहीं करता है, तोjavacकंपाइलर, बिल्ड-टाइम की गड़बड़ी दिखाता है. उदाहरण के लिए:गड़बड़ी का पहला उदाहरण:
javac MyList.javaMyList.java:135: error: removeLast() in MyList cannot implement removeLast() in List public void removeLast() { ^ return type void is not compatible with Object where E is a type-variable: E extends Object declared in interface Listगड़बड़ी का दूसरा उदाहरण:
javac MyList.javaMyList.java:7: error: types Deque<Object> and List<Object> are incompatible; public class MyList implements List<Object>, Deque<Object> { both define reversed(), but with unrelated return types 1 errorगड़बड़ी का तीसरा उदाहरण:
javac MyList.javaMyList.java:43: error: types List<E#1> and MyInterface<E#2> are incompatible; public static class MyList implements List<Object>, MyInterface<Object> { class MyList inherits unrelated defaults for getFirst() from types List and MyInterface where E#1,E#2 are type-variables: E#1 extends Object declared in interface List E#2 extends Object declared in interface MyInterface 1 errorबिल्ड से जुड़ी इन गड़बड़ियों को ठीक करने के लिए, इन इंटरफ़ेस को लागू करने वाली क्लास को, मिलते-जुलते रिटर्न टाइप के साथ इस तरीके को बदलना चाहिए. उदाहरण के लिए:
@Override public Object getFirst() { return List.super.getFirst(); }
सुरक्षा
Android 15 में, ऐसे बदलाव किए गए हैं जिनसे सिस्टम की सुरक्षा बेहतर होती है. इससे, नुकसान पहुंचाने वाले ऐप्लिकेशन से उपयोगकर्ताओं और ऐप्लिकेशन को सुरक्षित रखने में मदद मिलती है.
TLS के प्रतिबंधित वर्शन
Android 15 restricts the usage of TLS versions 1.0 and 1.1. These versions had previously been deprecated in Android, but are now disallowed for apps targeting Android 15.
बैकग्राउंड में सुरक्षित तरीके से गतिविधि लॉन्च करना
Android 15 protects users from malicious apps and gives them more control over their devices by adding changes that prevent malicious background apps from bringing other apps to the foreground, elevating their privileges, and abusing user interaction. Background activity launches have been restricted since Android 10 (API level 29).
Other changes
- Change
PendingIntentcreators to block background activity launches by default. This helps prevent apps from accidentally creating aPendingIntentthat could be abused by malicious actors. - Don't bring an app to the foreground unless the
PendingIntentsender allows it. This change aims to prevent malicious apps from abusing the ability to start activities in the background. By default, apps are not allowed to bring the task stack to the foreground unless the creator allows background activity launch privileges or the sender has background activity launch privileges. - Control how the top activity of a task stack can finish its task. If the top activity finishes a task, Android will go back to whichever task was last active. Moreover, if a non-top activity finishes its task, Android will go back to the home screen; it won't block the finish of this non-top activity.
- Prevent launching arbitrary activities from other apps into your own task. This change prevents malicious apps from phishing users by creating activities that appear to be from other apps.
- Block non-visible windows from being considered for background activity launches. This helps prevent malicious apps from abusing background activity launches to display unwanted or malicious content to users.
ज़्यादा सुरक्षित इंटेंट
Android 15 introduces StrictMode for
intents.
In order to see detailed logs about Intent usage violations, use following
method:
Kotlin
fun onCreate() { StrictMode.setVmPolicy(VmPolicy.Builder() .detectUnsafeIntentLaunch() .build() ) }
Java
public void onCreate() { StrictMode.setVmPolicy(new VmPolicy.Builder() .detectUnsafeIntentLaunch() .build()); }
लोगों का अनुभव और सिस्टम यूज़र इंटरफ़ेस (यूआई)
Android 15 में कुछ ऐसे बदलाव किए गए हैं जिनसे लोगों को ज़्यादा बेहतर और आसान अनुभव मिल सके.
विंडो इनसेट में बदलाव
Android 15 में, विंडो इनसेट से जुड़े दो बदलाव किए गए हैं: डिफ़ॉल्ट रूप से, स्क्रीन के किनारों तक विंडो दिखती है. साथ ही, कॉन्फ़िगरेशन में भी बदलाव किए गए हैं. जैसे, सिस्टम बार का डिफ़ॉल्ट कॉन्फ़िगरेशन.
Edge-to-edge enforcement
Apps are edge-to-edge by default on devices running Android 15 if the app is targeting Android 15 (API level 35).
This is a breaking change that might negatively impact your app's UI. The changes affect the following UI areas:
- Gesture handle navigation bar
- Transparent by default.
- Bottom offset is disabled so content draws behind the system navigation bar unless insets are applied.
setNavigationBarColorandR.attr#navigationBarColorare deprecated and don't affect gesture navigation.setNavigationBarContrastEnforcedandR.attr#navigationBarContrastEnforcedcontinue to have no effect on gesture navigation.
- 3-button navigation
- Opacity set to 80% by default, with color possibly matching the window background.
- Bottom offset disabled so content draws behind the system navigation bar unless insets are applied.
setNavigationBarColorandR.attr#navigationBarColorare set to match the window background by default. The window background must be a color drawable for this default to apply. This API is deprecated but continues to affect 3-button navigation.setNavigationBarContrastEnforcedandR.attr#navigationBarContrastEnforcedis true by default, which adds an 80% opaque background across 3-button navigation.
- Status bar
- Transparent by default.
- The top offset is disabled so content draws behind the status bar unless insets are applied.
setStatusBarColorandR.attr#statusBarColorare deprecated and have no effect on Android 15.setStatusBarContrastEnforcedandR.attr#statusBarContrastEnforcedare deprecated but still have an effect on Android 15.
- Display cutout
layoutInDisplayCutoutModeof non-floating windows must beLAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS.SHORT_EDGES,NEVER, andDEFAULTare interpreted asALWAYSso that users don't see a black bar caused by the display cutout and appear edge-to-edge.
The following example shows an app before and after targeting Android 15 (API level 35), and before and after applying insets. This example is not comprehensive, this might appear differently on Android Auto.
What to check if your app is already edge-to-edge
If your app is already edge-to-edge and applies insets, you are mostly unimpacted, except in the following scenarios. However, even if you think you aren't impacted, we recommend you test your app.
- You have a non-floating window, such as an
Activitythat usesSHORT_EDGES,NEVERorDEFAULTinstead ofLAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS. If your app crashes on launch, this might be due to your splashscreen. You can either upgrade the core splashscreen dependency to 1.2.0-alpha01 or later or setwindow.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutInDisplayCutoutMode.always. - There might be lower-traffic screens with occluded UI. Verify these
less-visited screens don't have occluded UI. Lower-traffic screens include:
- Onboarding or sign-in screens
- Settings pages
What to check if your app is not already edge-to-edge
If your app is not already edge-to-edge, you are most likely impacted. In addition to the scenarios for apps that are already edge-to-edge, you should consider the following:
- If your app uses Material 3 Components (
androidx.compose.material3) in compose, such asTopAppBar,BottomAppBar, andNavigationBar, these components are likely not impacted because they automatically handle insets. - If your app is using Material 2 Components (
androidx.compose.material) in Compose, these components don't automatically handle insets. However, you can get access to the insets and apply them manually. In androidx.compose.material 1.6.0 and later, use thewindowInsetsparameter to apply the insets manually forBottomAppBar,TopAppBar,BottomNavigation, andNavigationRail. Likewise, use thecontentWindowInsetsparameter forScaffold. - If your app uses views and Material Components
(
com.google.android.material), most views-based Material Components such asBottomNavigationView,BottomAppBar,NavigationRailView, orNavigationView, handle insets and require no additional work. However, you need to addandroid:fitsSystemWindows="true"if usingAppBarLayout. - For custom composables, apply the insets manually as padding. If your
content is within a
Scaffold, you can consume insets using theScaffoldpadding values. Otherwise, apply padding using one of theWindowInsets. - If your app is using views and
BottomSheet,SideSheetor custom containers, apply padding usingViewCompat.setOnApplyWindowInsetsListener. ForRecyclerView, apply padding using this listener and also addclipToPadding="false".
What to check if your app must offer custom background protection
If your app must offer custom background protection to 3-button navigation or
the status bar, your app should place a composable or view behind the system bar
using WindowInsets.Type#tappableElement() to get the 3-button
navigation bar height or WindowInsets.Type#statusBars.
Additional edge-to-edge resources
See the Edge to Edge Views and Edge to Edge Compose guides for additional considerations on applying insets.
Deprecated APIs
The following APIs are deprecated but not disabled:
R.attr#enforceStatusBarContrastR.attr#navigationBarColor(for 3 button navigation, with 80% alpha)Window#isStatusBarContrastEnforcedWindow#setNavigationBarColor(for 3 button navigation, with 80% alpha)Window#setStatusBarContrastEnforced
The following APIs are deprecated and disabled:
R.attr#navigationBarColor(for gesture navigation)R.attr#navigationBarDividerColorR.attr#statusBarColorWindow#setDecorFitsSystemWindowsWindow#getNavigationBarColorWindow#getNavigationBarDividerColorWindow#getStatusBarColorWindow#setNavigationBarColor(for gesture navigation)Window#setNavigationBarDividerColorWindow#setStatusBarColor
Stable configuration
अगर आपका ऐप्लिकेशन, Android 15 (एपीआई लेवल 35) या इसके बाद के वर्शन को टारगेट करता है, तो Configuration अब सिस्टम बार को शामिल किया जाएगा. अगर लेआउट का हिसाब लगाने के लिए, Configuration क्लास में स्क्रीन साइज़ का इस्तेमाल किया जाता है, तो आपको इसे बेहतर विकल्पों से बदलना चाहिए. जैसे, अपनी ज़रूरत के हिसाब से सही ViewGroup, WindowInsets या WindowMetricsCalculator.
Configuration, एपीआई 1 से उपलब्ध है. आम तौर पर, इसे Activity.onConfigurationChanged से लिया जाता है. इससे विंडो डेंसिटी, ओरिएंटेशन, और साइज़ जैसी जानकारी मिलती है. Configuration से मिले विंडो साइज़ की एक अहम खासियत यह है कि इसमें पहले सिस्टम बार शामिल नहीं होते थे.
कॉन्फ़िगरेशन साइज़ का इस्तेमाल आम तौर पर संसाधन चुनने के लिए किया जाता है. जैसे, /res/layout-h500dp. यह अब भी इस्तेमाल का मान्य उदाहरण है. हालांकि, लेआउट का हिसाब लगाने के लिए इसका इस्तेमाल करने से हमेशा मना किया जाता है. अगर आपने ऐसा किया है, तो आपको अब इससे दूर हो जाना चाहिए. आपको Configuration की जगह, अपनी ज़रूरत के हिसाब से कोई और बेहतर विकल्प इस्तेमाल करना चाहिए.
अगर आपको लेआउट का हिसाब लगाने के लिए इसका इस्तेमाल करना है, तो सही ViewGroup का इस्तेमाल करें. जैसे, CoordinatorLayout या ConstraintLayout. अगर इसका इस्तेमाल सिस्टम के नेवबार की ऊंचाई का पता लगाने के लिए किया जाता है, तो WindowInsets का इस्तेमाल करें. अगर आपको अपने ऐप्लिकेशन की विंडो का मौजूदा साइज़ जानना है, तो computeCurrentWindowMetrics का इस्तेमाल करें.
यहां दी गई सूची में, उन फ़ील्ड के बारे में बताया गया है जिन पर इस बदलाव का असर पड़ा है:
Configuration.screenWidthDpऔरscreenHeightDpसाइज़ में अब सिस्टम बार शामिल होते हैं.screenWidthDpऔरscreenHeightDpमें हुए बदलावों का असर,Configuration.smallestScreenWidthDpपर सीधे तौर पर नहीं पड़ता.Configuration.orientationपर, स्क्वेयर जैसे डिवाइसों परscreenWidthDpऔरscreenHeightDpमें किए गए बदलावों का असर पड़ता है.Display.getSize(Point)पर,Configurationमें हुए बदलावों का असर सीधे तौर पर नहीं पड़ता. एपीआई लेवल 30 से, इस सुविधा का इस्तेमाल बंद कर दिया गया है.Display.getMetrics(), एपीआई लेवल 33 से ही इस तरह काम कर रहा है.
elegantTextHeight एट्रिब्यूट, डिफ़ॉल्ट रूप से 'सही' पर सेट होता है
Android 15 (एपीआई लेवल 35) को टारगेट करने वाले ऐप्लिकेशन के लिए, elegantTextHeight TextView एट्रिब्यूट डिफ़ॉल्ट रूप से true हो जाता है. इससे, डिफ़ॉल्ट रूप से इस्तेमाल किए जाने वाले कॉम्पैक्ट फ़ॉन्ट की जगह, कुछ ऐसी स्क्रिप्ट का इस्तेमाल किया जाता है जिनमें बड़ी वर्टिकल मेट्रिक होती हैं. इन मेट्रिक को पढ़ना ज़्यादा आसान होता है.
कॉम्पैक्ट फ़ॉन्ट को लेआउट के बीच में रुकावट आने से रोकने के लिए लॉन्च किया गया था. Android 13 (एपीआई लेवल 33), fallbackLineSpacing एट्रिब्यूट का इस्तेमाल करके, टेक्स्ट लेआउट की वर्टिकल ऊंचाई को बढ़ाकर, इनमें से कई रुकावटों को रोकता है.
Android 15 में, कॉम्पैक्ट फ़ॉन्ट अब भी सिस्टम में मौजूद है. इसलिए, आपका ऐप्लिकेशन पहले जैसा व्यवहार पाने के लिए, elegantTextHeight को false पर सेट कर सकता है. हालांकि, आने वाले समय में रिलीज़ होने वाले वर्शन में, इसकी सुविधा काम नहीं करेगी. इसलिए, अगर आपका ऐप्लिकेशन इन स्क्रिप्ट के साथ काम करता है: ऐरेबिक, लाओ, म्यांमार, तमिल, गुजराती, कन्नड़, मलयालम, उड़ीया, तेलुगु या थाई, तो elegantTextHeight को true पर सेट करके अपने ऐप्लिकेशन की जांच करें.
elegantTextHeight Android 14 (एपीआई लेवल 34) और उससे पहले के वर्शन को टारगेट करने वाले ऐप्लिकेशन के लिए व्यवहार.
elegantTextHeight Android 15 को टारगेट करने वाले ऐप्लिकेशन के लिए व्यवहार.जटिल अक्षरों के आकार के लिए, TextView की चौड़ाई में बदलाव
Android के पिछले वर्शन में, पेचीदा आकार वाले कुछ कर्सिव फ़ॉन्ट या भाषाएं, पिछले या अगले वर्ण के एरिया में अक्षर खींच सकती हैं.
कुछ मामलों में, ऐसे अक्षरों को शुरुआत या आखिर में काटकर छोटा किया गया था.
Android 15 से, TextView ऐसे अक्षरों के लिए ज़रूरी जगह बनाने के लिए
चौड़ाई तय करता है. साथ ही, क्लिप बनाने से रोकने के लिए,
ऐप्लिकेशन बाईं ओर ज़्यादा पैडिंग (जगह) का अनुरोध कर सकते हैं.
इस बदलाव का असर इस बात पर पड़ता है कि TextView, चौड़ाई का फ़ैसला कैसे लेता है. इसलिए, अगर ऐप्लिकेशन Android 15 (एपीआई लेवल 35) या उसके बाद के वर्शन को टारगेट करता है, तो TextView डिफ़ॉल्ट रूप से ज़्यादा चौड़ाई तय करता है. setUseBoundsForWidth पर एपीआई को कॉल करके, इस सुविधा को चालू या बंद किया जा सकता है.TextView
बाईं ओर की पैडिंग जोड़ने से, हो सकता है कि मौजूदा लेआउट गलत तरीके से अलाइन हो जाएं. ऐसा होने पर, Android 15 या इसके बाद के वर्शन को टारगेट करने वाले ऐप्लिकेशन के लिए भी पैडिंग (जगह) डिफ़ॉल्ट रूप से नहीं जोड़ी जाती.
हालांकि, setShiftDrawingOffsetForStartOverhang को कॉल करके, क्लिपिंग को रोकने के लिए अतिरिक्त पैडिंग जोड़ी जा सकती है.
नीचे दिए गए उदाहरणों से पता चलता है कि इन बदलावों से कुछ फ़ॉन्ट और भाषाओं के लिए टेक्स्ट लेआउट को बेहतर कैसे बनाया जा सकता है.
<TextView android:fontFamily="cursive" android:text="java" />
<TextView android:fontFamily="cursive" android:text="java" android:useBoundsForWidth="true" android:shiftDrawingOffsetForStartOverhang="true" />
<TextView android:text="คอมพิวเตอร์" />
<TextView android:text="คอมพิวเตอร์" android:useBoundsForWidth="true" android:shiftDrawingOffsetForStartOverhang="true" />
EditText के लिए, स्थानीय भाषा के हिसाब से लाइन की डिफ़ॉल्ट ऊंचाई
In previous versions of Android, the text layout stretched the height of the
text to meet the line height of the font that matched the current locale. For
example, if the content was in Japanese, because the line height of the Japanese
font is slightly larger than the one of a Latin font, the height of the text
became slightly larger. However, despite these differences in line heights, the
EditText element was sized uniformly, regardless
of the locale being used, as illustrated in the following image:
EditText elements that
can contain text from English (en), Japanese (ja), and Burmese (my). The
height of the EditText is the same, even though these languages
have different line heights from each other.For apps targeting Android 15 (API level 35), a minimum line height is now
reserved for EditText to match the reference font for the specified Locale, as
shown in the following image:
EditText elements that
can contain text from English (en), Japanese (ja), and Burmese (my). The
height of the EditText now includes space to accommodate the
default line height for these languages' fonts.If needed, your app can restore the previous behavior by specifying the
useLocalePreferredLineHeightForMinimum attribute
to false, and your app can set custom minimum vertical metrics using the
setMinimumFontMetrics API in Kotlin and Java.
कैमरा और मीडिया
Android 15 या इसके बाद के वर्शन को टारगेट करने वाले ऐप्लिकेशन के लिए, Android 15 में कैमरा और मीडिया के बर्ताव में ये बदलाव किए गए हैं.
ऑडियो फ़ोकस के लिए अनुरोध करने पर लागू होने वाली पाबंदियां
Android 15 (एपीआई लेवल 35) को टारगेट करने वाले ऐप्लिकेशन को ऑडियो फ़ोकस का अनुरोध करने के लिए, टॉप ऐप्लिकेशन या फ़ोरग्राउंड सेवा के तौर पर चलना होगा. अगर कोई ऐप्लिकेशन इनमें से किसी एक ज़रूरी शर्त को पूरा न करने पर फ़ोकस का अनुरोध करता है, तो कॉल AUDIOFOCUS_REQUEST_FAILED दिखाता है.
ऑडियो फ़ोकस के बारे में ज़्यादा जानने के लिए, ऑडियो फ़ोकस मैनेज करें पर जाएं.
गैर-एसडीके से जुड़ी पाबंदियां अपडेट की गईं
Android 15 includes updated lists of restricted non-SDK interfaces based on collaboration with Android developers and the latest internal testing. Whenever possible, we make sure that public alternatives are available before we restrict non-SDK interfaces.
If your app does not target Android 15, some of these changes might not immediately affect you. However, while it's possible for your app to access some non-SDK interfaces depending on your app's target API level, using any non-SDK method or field always carries a high risk of breaking your app.
If you are unsure if your app uses non-SDK interfaces, you can test your app to find out. If your app relies on non-SDK interfaces, you should begin planning a migration to SDK alternatives. Nevertheless, we understand that some apps have valid use cases for using non-SDK interfaces. If you can't find an alternative to using a non-SDK interface for a feature in your app, you should request a new public API.
Android के इस वर्शन में हुए बदलावों के बारे में ज़्यादा जानने के लिए, Android 15 में, SDK टूल के अलावा अन्य इंटरफ़ेस से जुड़ी पाबंदियों में हुए अपडेट देखें. आम तौर पर, SDK टूल के बाहर के इंटरफ़ेस के बारे में ज़्यादा जानने के लिए, SDK टूल के बाहर के इंटरफ़ेस पर लगी पाबंदियां देखें.