Panoramica delle funzionalità e delle API

Android 14 introduce fantastiche funzionalità e API per gli sviluppatori. Di seguito puoi trovare informazioni sulle funzionalità per le tue app e iniziare a utilizzare le API correlate.

Per un elenco dettagliato delle API aggiunte, modificate e rimosse, leggi il report sulle differenze delle API. Per informazioni dettagliate sulle API aggiunte, consulta il riferimento all'API Android. Per Android 14, cerca le API aggiunte nel livello API 34. Per scoprire le aree in cui le modifiche alla piattaforma potrebbero influire sulle tue app, consulta le modifiche al comportamento di Android 14 per le app che hanno come target Android 14 e per tutte le app.

Internazionalizzazione

Lingua preferita nelle app

Android 14 espande le funzionalità per lingua per app introdotte in Android 13 (livello API 33) con le seguenti funzionalità aggiuntive:

  • Genera automaticamente il localeConfig di un'app: a partire da Android Studio Giraffe Canary 7 e AGP 8.1.0-alpha07, puoi configurare l'app in modo che supporti automaticamente le preferenze per le lingue per app. In base alle risorse del progetto, il plug-in Android per Gradle genera il file LocaleConfig e aggiunge un riferimento al file manifest finale, quindi non devi più creare o aggiornare il file manualmente. AGP utilizza le risorse nelle cartelle res dei moduli dell'app e eventuali dipendenze dei moduli della libreria per determinare le lingue da includere nel file LocaleConfig.

  • Aggiornamenti dinamici per il localeConfig di un'app: utilizza i metodi setOverrideLocaleConfig() e getOverrideLocaleConfig() in LocaleManager per aggiornare dinamicamente l'elenco delle lingue supportate della tua app nelle impostazioni di sistema del dispositivo. Utilizza questa flessibilità per personalizzare l'elenco delle lingue supportate per regione, eseguire esperimenti A/B o fornire un elenco aggiornato delle impostazioni internazionali se la tua app utilizza i push lato server per la localizzazione.

  • Visibilità della lingua dell'app per gli editor di metodi di immissione (IME): gli IME possono utilizzare il metodo getApplicationLocales() per controllare la lingua dell'app corrente e associare la lingua dell'IME a quella lingua.

API Grammatical Inflection

Tre miliardi di persone parlano lingue con genere: lingue in cui le categorie grammaticali, come nomi, verbi, aggettivi e preposizioni, si declinano in base al genere delle persone e degli oggetti di cui parli o a cui ti riferisci. Tradizionalmente, molte lingue con genere grammaticale utilizzano il genere grammaticale maschile come genere predefinito o generico.

Rivolgersi agli utenti con il genere grammaticale sbagliato, ad esempio alle donne con il genere grammaticale maschile, può influire negativamente sul loro rendimento e sul loro atteggiamento. Al contrario, un'interfaccia utente con un linguaggio che riflette correttamente il genere grammaticale dell'utente può migliorare il coinvolgimento dell'utente e offrire un'esperienza utente più personalizzata e dal suono naturale.

Per aiutarti a creare un'interfaccia utente incentrata sull'utente per le lingue con genere, Android 14 introduce l'API di flessione grammaticale, che ti consente di aggiungere il supporto per il genere grammaticale senza eseguire il refactoring dell'app.

Preferenze regionali

Le preferenze regionali consentono agli utenti di personalizzare le unità di misura della temperatura, il primo giorno della settimana e i sistemi di numerazione. Un europeo che vive negli Stati Uniti potrebbe preferire che le unità di misura della temperatura siano in gradi Celsius anziché Fahrenheit e che le app trattino il lunedì come inizio della settimana anziché la domenica, che è il valore predefinito negli Stati Uniti.

I nuovi menu Impostazioni Android per queste preferenze offrono agli utenti un punto di riferimento rilevabile e centralizzato per modificare le preferenze delle app. Queste preferenze rimangono invariate anche durante il backup e il ripristino. Diverse API e come intenti, getTemperatureUnit e getFirstDayOfWeek— Concedi alla tua app l'accesso in lettura alle preferenze dell'utente, in modo che possa regolare il modo in cui visualizza le informazioni. Puoi anche registrare un BroadcastReceiver attivo ACTION_LOCALE_CHANGED per gestire le modifiche alla configurazione delle impostazioni internazionali quando cambiano le preferenze regionali.

Per trovare queste impostazioni, apri l'app Impostazioni e seleziona Sistema > Lingue e input > Preferenze regionali.

Schermata delle preferenze regionali nelle impostazioni di sistema di Android.
Opzioni di temperatura per le preferenze regionali nel sistema Android impostazioni.

Accessibilità

Ridimensionamento non lineare dei caratteri al 200%

Starting in Android 14, the system supports font scaling up to 200%, providing low-vision users with additional accessibility options that align with Web Content Accessibility Guidelines (WCAG).

To prevent large text elements on screen from scaling too large, the system applies a nonlinear scaling curve. This scaling strategy means that large text doesn't scale at the same rate as smaller text. Nonlinear font scaling helps preserve the proportional hierarchy between elements of different sizes while mitigating issues with linear text scaling at high degrees (such as text being cut off or text that becomes harder to read due to an extremely large display sizes).

Test your app with nonlinear font scaling

Enable the maximum font size in a device's accessibility settings to test your app.

If you already use scaled pixels (sp) units to define text sizing, then these additional options and scaling improvements are applied automatically to the text in your app. However, you should still perform UI testing with the maximum font size enabled (200%) to ensure that your app applies the font sizes correctly and can accommodate larger font sizes without impacting usability.

To enable 200% font size, follow these steps:

  1. Open the Settings app and navigate to Accessibility > Display size and text.
  2. For the Font size option, tap the plus (+) icon until the maximum font size setting is enabled, as shown in the image that accompanies this section.

Use scaled pixel (sp) units for text-sizes

Remember to always specify text sizes in sp units. When your app uses sp units, Android can apply the user's preferred text size and scale it appropriately.

Don't use sp units for padding or define view heights assuming implicit padding: with nonlinear font scaling sp dimensions might not be proportional, so 4sp + 20sp might not equal 24sp.

Convert scaled pixel (sp) units

Use TypedValue.applyDimension() to convert from sp units to pixels, and use TypedValue.deriveDimension() to convert pixels to sp. These methods apply the appropriate nonlinear scaling curve automatically.

Avoid hardcoding equations using Configuration.fontScale or DisplayMetrics.scaledDensity. Because font scaling is nonlinear, the scaledDensity field is no longer accurate. The fontScale field should be used for informational purposes only because fonts are no longer scaled with a single scalar value.

Use sp units for lineHeight

Always define android:lineHeight using sp units instead of dp, so the line height scales along with your text. Otherwise, if your text is sp but your lineHeight is in dp or px, it doesn't scale and looks cramped. TextView automatically corrects the lineHeight so that your intended proportions are preserved, but only if both textSize and lineHeight are defined in sp units.

Fotocamera e contenuti multimediali

Ultra HDR per le immagini

标准动态范围 (SDR) 与高动态范围 (HDR) 图片质量对比示意图。

Android 14 新增了对高动态范围 (HDR) 图片的支持,可在拍摄照片时保留更多来自传感器的信息,从而实现鲜艳的色彩和更高的对比度。Android 使用 Ultra HDR 格式,该格式与 JPEG 图片完全向后兼容,可让应用与 HDR 图片无缝互操作,并根据需要以标准动态范围 (SDR) 显示这些图片。

当您的应用选择为其 activity 窗口使用 HDR 界面(通过清单条目或通过在运行时调用 Window.setColorMode())时,框架会自动在界面中以 HDR 格式渲染这些图片。您还可以在受支持的设备上拍摄压缩的 Ultra HDR 静态图片。从传感器中恢复的颜色越多,后期编辑的灵活性就越高。与 Ultra HDR 图片关联的 Gainmap 可用于使用 OpenGL 或 Vulkan 渲染这些图片。

Zoom, messa a fuoco, postview e altro ancora nelle estensioni della fotocamera

Android 14 upgrades and improves camera extensions, allowing apps to handle longer processing times, which enables improved images using compute-intensive algorithms like low-light photography on supported devices. These features give users an even more robust experience when using camera extension capabilities. Examples of these improvements include:

Zoom in-sensor

When REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE in CameraCharacteristics contains SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW, your app can use advanced sensor capabilities to give a cropped RAW stream the same pixels as the full field of view by using a CaptureRequest with a RAW target that has stream use case set to CameraMetadata.SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW. By implementing the request override controls, the updated camera gives users zoom control even before other camera controls are ready.

Audio USB senza perdita di dati

Android 14 supporta i formati audio lossless per esperienze di livello audiophile tramite cuffie con cavo USB. Puoi eseguire query su un dispositivo USB per gli attributi del mixer preferiti, registrare un ascoltatore per le modifiche agli attributi del mixer preferiti e configurare gli attributi del mixer utilizzando la classe AudioMixerAttributes. Questa classe rappresenta il formato, ad esempio la maschera del canale, la frequenza di campionamento e il comportamento del mixer audio. La classe consente di inviare l'audio direttamente, senza miscelazione, regolazione del volume o effetti di elaborazione.

Produttività e strumenti per sviluppatori

Gestore delle credenziali

Android 14 adds Credential Manager as a platform API, with additional support back to Android 4.4 (API level 19) devices through a Jetpack Library using Google Play services. Credential Manager aims to make sign-in easier for users with APIs that retrieve and store credentials with user-configured credential providers. Credential Manager supports multiple sign-in methods, including username and password, passkeys, and federated sign-in solutions (such as Sign-in with Google) in a single API.

Passkeys provide many advantages. For example, passkeys are built on industry standards, can work across different operating systems and browser ecosystems, and can be used with both websites and apps.

For more information, see the Credential Manager and passkeys documentation and the blogpost about Credential Manager and passkeys.

Connessione Salute

Health Connect is an on-device repository for user health and fitness data. It allows users to share data between their favorite apps, with a single place to control what data they want to share with these apps.

On devices running Android versions prior to Android 14, Health Connect is available to download as an app on the Google Play store. Starting with Android 14, Health Connect is part of the platform and receives updates through Google Play system updates without requiring a separate download. With this, Health Connect can be updated frequently, and your apps can rely on Health Connect being available on devices running Android 14 or higher. Users can access Health Connect from the Settings in their device, with privacy controls integrated into the system settings.

Users can get started using Health Connect without a separate app download on devices running Android 14 or higher.
Users can control which apps have access to their health and fitness data through system settings.

Health Connect includes several new features in Android 14, such as exercise routes, allowing users to share a route of their workout which can be visualized on a map. A route is defined as a list of locations saved within a window of time, and your app can insert routes into exercise sessions, tying them together. To ensure that users have complete control over this sensitive data, users must allow sharing individual routes with other apps.

For more information, see the Health Connection documentation and the blogpost on What's new in Android Health.

Aggiornamenti di OpenJDK 17

Android 14 continua l'opera di aggiornamento delle librerie di base di Android per allinearsi alle funzionalità delle ultime release OpenJDK LTS, inclusi gli aggiornamenti delle librerie e il supporto del linguaggio Java 17 per gli sviluppatori di app e piattaforme.

Sono incluse le seguenti funzionalità e i seguenti miglioramenti:

  • Sono stati aggiornati circa 300 corsi java.base per il supporto di Java 17.
  • Blocchi di testo, che introducono stringhe letterali su più righe nel linguaggio di programmazione Java.
  • Corrispondenza pattern per instanceof, che consente di trattare un oggetto come se avesse un tipo specifico in un instanceof senza variabili aggiuntive.
  • Classi sigillate, che ti consentono di limitare le classi e le interfacce che possono estenderle o implementarle.

Grazie agli aggiornamenti di sistema Google Play (Project Mainline), oltre 600 milioni di dispositivi sono abilitati a ricevere gli aggiornamenti più recenti di Android Runtime (ART) che includono queste modifiche. Ciò fa parte del nostro impegno a offrire alle app un ambiente più coerente e sicuro su tutti i dispositivi e a fornire nuove funzionalità e capacità agli utenti indipendentemente dalle release della piattaforma.

Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.

Miglioramenti per gli store di app

Android 14 introduces several PackageInstaller APIs that allow app stores to improve their user experience.

Request install approval before downloading

Installing or updating an app might require user approval. For example, when an installer making use of the REQUEST_INSTALL_PACKAGES permission attempts to install a new app. In prior Android versions, app stores can only request user approval after APKs are written to the install session and the session is committed.

Starting with Android 14, the requestUserPreapproval() method lets installers request user approval before committing the install session. This improvement lets an app store defer downloading any APKs until after the installation has been approved by the user. Furthermore, once a user has approved installation, the app store can download and install the app in the background without interrupting the user.

Claim responsibility for future updates

The setRequestUpdateOwnership() method allows an installer to indicate to the system that it intends to be responsible for future updates to an app it is installing. This capability enables update ownership enforcement, meaning that only the update owner is permitted to install automatic updates to the app. Update ownership enforcement helps to ensure that users receive updates only from the expected app store.

Any other installer, including those making use of the INSTALL_PACKAGES permission, must receive explicit user approval in order to install an update. If a user decides to proceed with an update from another source, update ownership is lost.

Update apps at less-disruptive times

App stores typically want to avoid updating an app that is actively in use because this leads to the app's running processes being killed, which potentially interrupts what the user was doing.

Starting with Android 14, the InstallConstraints API gives installers a way to ensure that their app updates happen at an opportune moment. For example, an app store can call the commitSessionAfterInstallConstraintsAreMet() method to make sure that an update is only committed when the user is no longer interacting with the app in question.

Seamlessly install optional splits

With split APKs, features of an app can be delivered in separate APK files, rather than as a monolithic APK. Split APKs allow app stores to optimize the delivery of different app components. For example, app stores might optimize based on the properties of the target device. The PackageInstaller API has supported splits since its introduction in API level 22.

In Android 14, the setDontKillApp() method allows an installer to indicate that the app's running processes shouldn't be killed when new splits are installed. App stores can use this feature to seamlessly install new features of an app while the user is using the app.

Bundle di metadati delle app

Starting in Android 14, the Android package installer lets you specify app metadata, such as data safety practices, to include on app store pages such as Google Play.

Rilevare quando gli utenti acquisiscono screenshot del dispositivo

Per creare un'esperienza più standardizzata per il rilevamento degli screenshot, Android 14 introduce un'API di rilevamento degli screenshot che tutela la privacy. Questa API consente alle app di registrare i callback in base all'attività. Questi callback vengono richiamati e l'utente riceve una notifica quando acquisisce uno screenshot mentre l'attività è visibile.

Esperienza utente

Azioni personalizzate della scheda di condivisione e ranking migliorato

Android 14 updates the system sharesheet to support custom app actions and more informative preview results for users.

Add custom actions

With Android 14, your app can add custom actions to the system sharesheet it invokes.

Screenshot of custom actions on the sharesheet.

Improve ranking of Direct Share targets

Android 14 uses more signals from apps to determine the ranking of the direct share targets to provide more helpful results for the user. To provide the most useful signal for ranking, follow the guidance for improving rankings of your Direct Share targets. Communication apps can also report shortcut usage for outgoing and incoming messages.

Direct Share row in the sharesheet, as shown by 1

Supporto di animazioni integrate e personalizzate per il gesto Indietro predittivo

视频:预测性返回动画

Android 13 在开发者选项背后引入了预测性“返回主屏幕”动画。在已启用开发者选项的受支持应用中使用时,滑回手势会显示动画,表明返回手势会使应用退回到主屏幕。

Android 14 包含针对“预测性返回”的多项改进和新指南:

在此 Android 14 预览版中,所有预测性返回功能都是位于开发者选项背后。请参阅与将您的应用迁移到预测性返回有关的开发者指南,以及与创建自定义应用内转换有关的开发者指南

Sostituzioni per app dei produttori di dispositivi con schermo grande

Gli override per app consentono ai produttori di modificare il comportamento delle app sui dispositivi con schermi grandi. Ad esempio, l'override FORCE_RESIZE_APP indica al sistema di ridimensionare l'app in base alle dimensioni del display (evitando la modalità di compatibilità delle dimensioni) anche se resizeableActivity="false" è impostato nel file manifest dell'app.

Le sostituzioni hanno lo scopo di migliorare l'esperienza utente su schermi di grandi dimensioni.

Le nuove proprietà del file manifest ti consentono di disattivare alcuni override del produttore del dispositivo per la tua app.

Sostituzioni per app per utente con schermo grande

按应用替换项会更改应用在大屏设备上的行为。例如,无论应用的配置如何,OVERRIDE_MIN_ASPECT_RATIO_LARGE 设备制造商替换项都会将应用宽高比设置为 16:9。

借助 Android 14 QPR1,用户可以在大屏设备上通过新的设置菜单应用按应用替换项。

Condivisione della schermata dell'app

La condivisione dello schermo dell'app consente agli utenti di condividere una finestra dell'app anziché l'intero schermo del dispositivo durante la registrazione dei contenuti dello schermo.

Con la condivisione schermo dell'app, la barra di stato, la barra di navigazione, le notifiche e altri elementi dell'interfaccia utente di sistema sono esclusi dalla visualizzazione condivisa. Vengono condivisi solo i contenuti dell'app selezionata.

La condivisione dello schermo dell'app migliora la produttività e la privacy consentendo agli utenti di eseguire più app, ma limitando la condivisione dei contenuti a una singola app.

Risposta rapida basata su LLM in Gboard su Pixel 8 Pro

On Pixel 8 Pro devices with the December Feature Drop, developers can try out higher-quality smart replies in Gboard powered by on-device Large Language Models (LLMs) running on Google Tensor.

This feature is available as a limited preview for US English in WhatsApp, Line, and KakaoTalk. It requires using a Pixel 8 Pro device with Gboard as your keyboard.

To try it out, first enable the feature in Settings > Developer Options > AiCore Settings > Enable Aicore Persistent.

Next, open a conversation in a supported app to see LLM-powered Smart Reply in Gboard's suggestion strip in response to incoming messages.

Gboard utilizes on-device LLMs to provide higher-quality smart replies.

Grafica

I percorsi sono interrogabili e interpolabili

Android's Path API is a powerful and flexible mechanism for creating and rendering vector graphics, with the ability to stroke or fill a path, construct a path from line segments or quadratic or cubic curves, perform boolean operations to get even more complex shapes, or all of these simultaneously. One limitation is the ability to find out what is actually in a Path object; the internals of the object are opaque to callers after creation.

To create a Path, you call methods such as moveTo(), lineTo(), and cubicTo() to add path segments. But there has been no way to ask that path what the segments are, so you must retain that information at creation time.

Starting in Android 14, you can query paths to find out what's inside of them. First, you need to get a PathIterator object using the Path.getPathIterator API:

Kotlin

val path = Path().apply {
    moveTo(1.0f, 1.0f)
    lineTo(2.0f, 2.0f)
    close()
}
val pathIterator = path.pathIterator

Java

Path path = new Path();
path.moveTo(1.0F, 1.0F);
path.lineTo(2.0F, 2.0F);
path.close();
PathIterator pathIterator = path.getPathIterator();

Next, you can call PathIterator to iterate through the segments one by one, retrieving all of the necessary data for each segment. This example uses PathIterator.Segment objects, which packages up the data for you:

Kotlin

for (segment in pathIterator) {
    println("segment: ${segment.verb}, ${segment.points}")
}

Java

while (pathIterator.hasNext()) {
    PathIterator.Segment segment = pathIterator.next();
    Log.i(LOG_TAG, "segment: " + segment.getVerb() + ", " + segment.getPoints());
}

PathIterator also has a non-allocating version of next() where you can pass in a buffer to hold the point data.

One of the important use cases of querying Path data is interpolation. For example, you might want to animate (or morph) between two different paths. To further simplify that use case, Android 14 also includes the interpolate() method on Path. Assuming the two paths have the same internal structure, the interpolate() method creates a new Path with that interpolated result. This example returns a path whose shape is halfway (a linear interpolation of .5) between path and otherPath:

Kotlin

val interpolatedResult = Path()
if (path.isInterpolatable(otherPath)) {
    path.interpolate(otherPath, .5f, interpolatedResult)
}

Java

Path interpolatedResult = new Path();
if (path.isInterpolatable(otherPath)) {
    path.interpolate(otherPath, 0.5F, interpolatedResult);
}

The Jetpack graphics-path library enables similar APIs for earlier versions of Android as well.

Mesh personalizzati con shader di vertici e frammenti

Android supporta da tempo il disegno di mesh triangolari con ombreggiatura personalizzata, ma il formato della mesh di input è stato limitato a poche combinazioni di attributi predefinite. Android 14 aggiunge il supporto per le matrici personalizzate, che possono essere definite come triangoli o strisce di triangoli, e possono, facoltativamente, essere indicizzate. Questi mesh sono specificati con attributi personalizzati, passi di vertice, variabili e shader di vertici e frammenti scritti in AGSL.

Lo shader vertex definisce le varianti, come posizione e colore, mentre lo shader fragment può facoltativamente definire il colore del pixel, in genere utilizzando le varianti create dallo shader vertex. Se il colore viene fornito dall'shader frammento, viene mischiato con il colore Paint corrente utilizzando la modalità di miscela selezionata durante il disegno del mesh. Le uniformi possono essere passate agli shader di frammento e vertice per una maggiore flessibilità.

Renderer del buffer hardware per Canvas

Per facilitare l'utilizzo dell'API Canvas di Android per disegnare con accelerazione hardware in un HardwareBuffer, Android 14 introduce HardwareBufferRenderer. Questa API è particolarmente utile quando il caso d'uso prevede la comunicazione con il compositore di sistema tramite SurfaceControl per il disegno con bassa latenza.