Panoramica di funzionalità e API

Android 14 introduce funzionalità e API eccezionali per gli sviluppatori. Di seguito puoi scoprire le 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 maggiori dettagli sulle API aggiunte, visita il Riferimento API Android. Per Android 14, cerca le API che sono state aggiunte nel livello API 34. Per scoprire di più sulle aree in cui le modifiche alla piattaforma potrebbero interessare le tue app, assicurati di controllare i cambiamenti di comportamento di Android 14 per le app destinate ad Android 14 e per tutte le app.

Internazionalizzazione

Lingua preferita nelle app

Android 14 expands on the per-app language features that were introduced in Android 13 (API level 33) with these additional capabilities:

  • Automatically generate an app's localeConfig: Starting with Android Studio Giraffe Canary 7 and AGP 8.1.0-alpha07, you can configure your app to support per-app language preferences automatically. Based on your project resources, the Android Gradle plugin generates the LocaleConfig file and adds a reference to it in the final manifest file, so you no longer have to create or update the file manually. AGP uses the resources in the res folders of your app modules and any library module dependencies to determine the locales to include in the LocaleConfig file.

  • Dynamic updates for an app's localeConfig: Use the setOverrideLocaleConfig() and getOverrideLocaleConfig() methods in LocaleManager to dynamically update your app's list of supported languages in the device's system settings. Use this flexibility to customize the list of supported languages per region, run A/B experiments, or provide an updated list of locales if your app utilizes server-side pushes for localization.

  • App language visibility for input method editors (IMEs): IMEs can utilize the getApplicationLocales() method to check the language of the current app and match the IME language to that language.

API Grammatical Inflection

3 miliardi di persone parlano lingue di genere: lingue in cui le categorie grammaticali, come sostantivi, verbi, aggettivi e preposizioni, si adattano al genere delle persone e degli oggetti di cui parli o di cui parli. Tradizionalmente, molte lingue di genere utilizzano il genere grammaticale maschile come genere predefinito o generico.

Rivolgersi agli utenti utilizzando un genere grammaticale errato, ad esempio rivolgendosi alle donne in genere grammaticale maschile, può influire negativamente sul loro rendimento e sul loro atteggiamento. Al contrario, una UI con un linguaggio che riflette correttamente il genere grammaticale dell'utente può migliorare il coinvolgimento dell'utente e fornire un'esperienza utente più personalizzata e naturale.

Per aiutarti a creare un'interfaccia utente incentrata sull'utente per le lingue di genere, Android 14 introduce l'API Grammatical Inflection, che consente di aggiungere supporto per il genere grammaticale senza dover ricorrere al 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 dei caratteri non lineari 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

Illustrazione della qualità delle immagini SDR (Standard Dynamic Range) e della qualità delle immagini HDR (High Dynamic Range).

Android 14 aggiunge il supporto per le immagini HDR (High Dynamic Range), che conservano una quantità maggiore di informazioni provenienti dal sensore quando si scatta una foto, consentendo colori vivaci e un maggiore contrasto. Android utilizza il formato Ultra HDR, completamente compatibile con le immagini JPEG, che consente alle app di interagire senza problemi con le immagini HDR, mostrandole in modalità Standard Dynamic Range (SDR) in base alle esigenze.

Il rendering di queste immagini nell'interfaccia utente in HDR viene eseguito automaticamente dal framework quando l'app attiva l'utilizzo dell'UI HDR per la finestra attività, tramite una voce del file manifest o in fase di runtime chiamando Window.setColorMode(). Puoi anche acquisire fermi immagine Ultra HDR compressi sui dispositivi supportati. Con più colori recuperati dal sensore, l'editing in post può essere più flessibile. L'elemento Gainmap associato alle immagini Ultra HDR può essere usato per eseguirne il rendering con OpenGL o Vulkan.

Zoom, Messa a fuoco, Postview e altro nelle estensioni fotocamera

Android 14 esegue l'upgrade e migliora le estensioni della fotocamera, consentendo alle app di gestire tempi di elaborazione più lunghi. Ciò permette di migliorare le immagini grazie ad algoritmi ad alta intensità di calcolo come le fotografie in condizioni di scarsa illuminazione sui dispositivi supportati. Queste caratteristiche offrono agli utenti un'esperienza ancora più solida quando utilizzano le funzionalità delle estensioni della videocamera. Ecco alcuni esempi di questi miglioramenti:

Zoom nel sensore

Se REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE in CameraCharacteristics contiene SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW, la tua app può utilizzare le funzionalità avanzate dei sensori per ottenere gli stessi pixel dell'intero campo visivo in uno stream RAW ritagliato utilizzando un oggetto CaptureRequest con un target RAW con il caso d'uso dello stream impostato su CameraMetadata.SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW. Implementando i controlli di override delle richieste, la videocamera aggiornata offre agli utenti il controllo zoom prima ancora che siano pronti gli altri controlli della videocamera.

Audio USB senza perdita

Android 14 supporta i formati audio senza perdita di dati per le esperienze a livello audiofilo sulle cuffie USB con cavo. Puoi eseguire una query su un dispositivo USB per conoscere gli attributi del mixer preferiti, registrare un listener 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 mix, 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 è un repository sul dispositivo contenente i dati relativi alla salute e all'attività fisica degli utenti. Consente agli utenti di condividere dati tra le loro app preferite, con un unico posto in cui controllare quali dati condividere con queste app.

Sui dispositivi con versioni di Android precedenti ad Android 14, Connessione Salute può essere scaricata come app dal Google Play Store. A partire da Android 14, Connessione Salute fa parte della piattaforma e riceve aggiornamenti tramite gli aggiornamenti di sistema Google Play senza richiedere un download separato. Grazie a questa funzionalità, Connessione Salute può essere aggiornata di frequente e le tue app possono fare affidamento sulla disponibilità di Connessione Salute sui dispositivi con Android 14 o versioni successive. Gli utenti possono accedere a Connessione Salute dalle Impostazioni del proprio dispositivo, con controlli per la privacy integrati nelle impostazioni di sistema.

Gli utenti possono iniziare a utilizzare Connessione Salute senza dover scaricare un'app separata sui dispositivi con Android 14 o versioni successive.
Gli utenti possono controllare quali app possono accedere ai propri dati relativi a salute e attività fisica tramite le impostazioni di sistema.

Connessione Salute include diverse nuove funzionalità di Android 14, come i percorsi per l'allenamento, che consentono agli utenti di condividere un percorso dell'allenamento che può essere visualizzato su una mappa. Un percorso è definito come un elenco di luoghi salvati in una finestra di tempo e la tua app può inserire percorsi in sessioni di allenamento, collegandoli insieme. Per garantire che gli utenti abbiano il controllo completo su questi dati sensibili, devono consentire la condivisione di singole route con altre app.

Per ulteriori informazioni, consulta la documentazione di Connessione Salute e il post del blog su Novità di Android Health.

Aggiornamenti di OpenJDK 17

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

Sono inclusi le funzionalità e i miglioramenti seguenti:

  • Sono state aggiornate circa 300 classi java.base al supporto di Java 17.
  • Text Blocks, che introduce valori letterali stringa su più righe nel linguaggio di programmazione Java.
  • Corrispondenza di pattern per instanceof, che consente a un oggetto di essere trattato come se avesse un tipo specifico in un instanceof senza alcuna variabile aggiuntiva.
  • Classi protette, che 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 ultimi aggiornamenti di Android Runtime (ART) che includono queste modifiche. Ciò rientra nel nostro impegno a offrire alle app un ambiente più coerente e sicuro su tutti i dispositivi e a offrire nuove funzionalità 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

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.

App bundle di metadati

A partire da Android 14, il programma di installazione dei pacchetti Android ti consente di specificare i metadati dell'app, ad esempio le misure di sicurezza dei dati, da includere nelle pagine dello store come Google Play.

Rileva quando gli utenti acquisiscono screenshot del dispositivo

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

Esperienza utente

Azioni personalizzate di Sharesheet e miglioramento del ranking

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 per animazioni integrate e personalizzate per il sistema Indietro predittivo

Video: Predictive back animations

Android 13 introduced the predictive back-to-home animation behind a developer option. When used in a supported app with the developer option enabled, swiping back shows an animation indicating that the back gesture exits the app back to the home screen.

Android 14 includes multiple improvements and new guidance for Predictive Back:

With this Android 14 preview release, all features of Predictive Back remain behind a developer option. See the developer guide to migrate your app to predictive back, as well as the developer guide to creating custom in-app transitions.

Override per app del produttore di dispositivi con schermi di grandi dimensioni

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.

Override per app utente su schermi di grandi dimensioni

L'override per app modifica il comportamento delle app sui dispositivi con schermi grandi. Ad esempio, l'override del produttore del dispositivo OVERRIDE_MIN_ASPECT_RATIO_LARGE imposta le proporzioni dell'app su 16:9, indipendentemente dalla sua configurazione.

Android 14 QPR1 consente agli utenti di applicare override per app tramite un nuovo menu delle impostazioni sui dispositivi con schermi grandi.

Condivisione schermo dell'app

La condivisione schermo delle 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 delle app, la barra di stato, la barra di navigazione, le notifiche e altri elementi dell'interfaccia utente di sistema vengono esclusi dalla visualizzazione condivisa. Vengono condivisi solo i contenuti dell'app selezionata.

La condivisione schermo delle app migliora la produttività e la privacy consentendo agli utenti di eseguire più app, ma limita 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 vertex e frammenti

Android has long supported drawing triangle meshes with custom shading, but the input mesh format has been limited to a few predefined attribute combinations. Android 14 adds support for custom meshes, which can be defined as triangles or triangle strips, and can, optionally, be indexed. These meshes are specified with custom attributes, vertex strides, varying, and vertex and fragment shaders written in AGSL.

The vertex shader defines the varyings, such as position and color, while the fragment shader can optionally define the color for the pixel, typically by using the varyings created by the vertex shader. If color is provided by the fragment shader, it is then blended with the current Paint color using the blend mode selected when drawing the mesh. Uniforms can be passed into the fragment and vertex shaders for additional flexibility.

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.