Best practice per le scorciatoie
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Quando progetti e crei le scorciatoie della tua app, segui queste linee guida:
-
Segui le linee guida per la progettazione
-
Per rendere le scorciatoie della tua app visivamente coerenti con quelle utilizzate per le app di sistema, segui le linee guida per la progettazione delle icone delle scorciatoie app.
-
Pubblicare solo quattro scorciatoie distinte
-
Sebbene l'API supporti una combinazione di un massimo di 15 scorciatoie statiche e dinamiche per la tua app, ti consigliamo di pubblicare solo quattro scorciatoie distinte, per migliorarne l'aspetto visivo in Avvio app.
Oltre a visualizzare le scorciatoie in Avvio app, utilizza la libreria di integrazione delle scorciatoie di Google per mostrare le scorciatoie sulle piattaforme Google come l'Assistente Google. Questa libreria supporta il push di un numero illimitato di scorciatoie dinamiche. Se utilizzi questa libreria per eseguire il push di un numero elevato di scorciatoie, ti consigliamo di impostare il rank
delle scorciatoie che devono essere visualizzate nei Avvio app supportati chiamando il metodo setRank()
.
-
Limita la lunghezza della descrizione della scorciatoia
-
Lo spazio nel menu che mostra le scorciatoie dell'app in Avvio app è limitato. Se possibile, limita la lunghezza della "descrizione breve" di una scorciatoia a 10 caratteri e limita la lunghezza della "descrizione lunga" a 25 caratteri.
Per saperne di più sulle etichette per le scorciatoie statiche, consulta Personalizzare i valori degli attributi.
Per le scorciatoie dinamiche e bloccate, leggi la documentazione di riferimento su
setLongLabel()
e
setShortLabel()
.
-
Gestire la cronologia di utilizzo di scorciatoie e azioni
-
Per ogni scorciatoia che crei, considera i diversi modi in cui un utente può eseguire la stessa attività direttamente all'interno dell'app. Chiama reportShortcutUsed()
in ognuna di queste situazioni per fare in modo che Avvio app mantenga una cronologia accurata della frequenza con cui un utente esegue le azioni che rappresentano le tue scorciatoie.
-
Aggiornare le scorciatoie solo quando il loro significato viene conservato
-
Quando modifichi le scorciatoie dinamiche e bloccate, chiama
updateShortcuts()
solo se modifichi le informazioni di una scorciatoia che conserva il suo significato. In caso contrario, utilizza uno dei seguenti metodi, a seconda del tipo di scorciatoia che stai ricreando:
Ad esempio, se crei una scorciatoia per raggiungere un supermercato, è opportuno aggiornarla se il nome del supermercato cambia ma la sua posizione rimane invariata. Se
l'utente inizia a fare acquisti in un altro supermercato, tuttavia, è meglio creare una nuova
scorciatoia.
-
Controllare le scorciatoie dinamiche ogni volta che avvii l'app
-
Le scorciatoie dinamiche non vengono mantenute quando l'utente ripristina i suoi dati su un nuovo dispositivo. Per questo motivo, ti consigliamo di controllare il numero di oggetti restituiti da getDynamicShortcuts()
ogni volta che avvii l'app e ripubblicare le scorciatoie dinamiche secondo necessità, come mostrato nello snippet di codice in Backup e ripristino.
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-07-27 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-27 UTC."],[],[],null,["# Best practices for shortcuts\n\nWhen designing and creating your app's shortcuts, follow these guidelines:\n\n\n**Follow the design guidelines**\n\n: To make your app's shortcuts visually consistent with the shortcuts used for system apps, follow\n the\n [App Shortcuts Icon Design Guidelines](/static/shareables/design/app-shortcuts-design-guidelines.pdf).\n\n\n**Publish only four distinct shortcuts**\n\n: Although the API supports a combination of up to 15 static and dynamic shortcuts for your app, we\n recommend that you publish only four distinct shortcuts, to improve their visual appearance in the\n launcher.\n\n In addition to displaying shortcuts on the launcher, use the\n [Google Shortcuts Integration Library](/develop/ui/views/launch/shortcuts/creating-shortcuts#gsi-library)\n to display shortcuts on Google surfaces such as Google Assistant. This library supports pushing an\n unlimited number of dynamic shortcuts. If you are using this library to push a large number of\n shortcuts, we recommend setting the `rank` of the shortcuts that must appear in supported\n launchers by calling the\n [](/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setRank(int))`setRank()`\n method.\n\n\n**Limit shortcut description length**\n\n: The space in the menu that shows your app's shortcuts in the launcher is limited. When possible,\n limit the length of the \"short description\" of a shortcut to 10 characters and limit the length of\n the \"long description\" to 25 characters.\n\n For more information about labels for static shortcuts, read\n [Customize attribute values](/guide/topics/ui/shortcuts/creating-shortcuts#attribute-values).\n For dynamic and pinned shortcuts, read the reference documentation on\n [setLongLabel()](/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setLongLabel(java.lang.CharSequence))\n and\n [setShortLabel()](/reference/androidx/core/content/pm/ShortcutInfoCompat.Builder#setShortLabel(java.lang.CharSequence)).\n\n\n**Maintain shortcut and action usage history**\n\n: For each shortcut you create, consider the different ways a user can accomplish the same task\n directly within your app. Call\n [reportShortcutUsed()](/reference/androidx/core/content/pm/ShortcutManagerCompat#reportShortcutUsed(android.content.Context,%20java.lang.String))\n in each of these situations so that the launcher maintains an accurate history of how frequently a\n user performs the actions representing your shortcuts.\n\n\n**Update shortcuts only when their meaning is retained**\n\n: When changing dynamic and pinned shortcuts, only call\n [updateShortcuts()](/reference/androidx/core/content/pm/ShortcutManagerCompat#updateShortcuts(android.content.Context,%20java.util.List%3Candroidx.core.content.pm.ShortcutInfoCompat%3E))\n when changing the information of a shortcut that retains its meaning. Otherwise, use one of the\n following methods, depending on the type of shortcut you're recreating:\n\n - Dynamic shortcuts: [pushDynamicShortcut()](/reference/androidx/core/content/pm/ShortcutManagerCompat#pushDynamicShortcut(android.content.Context,%20androidx.core.content.pm.ShortcutInfoCompat)).\n - Pinned shortcuts: [requestPinShortcut()](/reference/androidx/core/content/pm/ShortcutManagerCompat#requestPinShortcut(android.content.Context,%20androidx.core.content.pm.ShortcutInfoCompat,%20android.content.IntentSender)).\n\n For example, if you create a shortcut for navigating to a supermarket, it is appropriate to\n update the shortcut if the name of the supermarket changes but its location stays the same. If the\n user begins shopping at a different supermarket location, however, it's better to create a new\n shortcut.\n\n\n**Check dynamic shortcuts whenever you launch your app**\n\n: Dynamic shortcuts aren't preserved when the user restores their data onto a new device. For this\n reason, we recommend that you check the number of objects returned by\n [getDynamicShortcuts()](/reference/androidx/core/content/pm/ShortcutManagerCompat#getDynamicShortcuts(android.content.Context))\n each time you launch your app and re-publish dynamic shortcuts as needed, as shown in the code\n snippet in\n [Backup and restore](/guide/topics/ui/shortcuts/managing-shortcuts#backup-restore)."]]