שיטות מומלצות לקיצורי דרך
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
כשמעצבים ויוצרים את קיצורי הדרך של האפליקציה, חשוב לפעול לפי ההנחיות הבאות:
-
הקפדה על הנחיות העיצוב
-
כדי שקיצורי הדרך של האפליקציה יהיו עקביים מבחינה ויזואלית עם קיצורי הדרך שמשמשים לאפליקציות מערכת, צריך לפעול לפי ההנחיות לעיצוב סמלים של קיצורי דרך לאפליקציות.
-
פרסום של ארבעה קיצורי דרך שונים בלבד
-
למרות שה-API תומך בשילוב של עד 15 קיצורי דרך סטטיים ודינמיים לאפליקציה, מומלץ לפרסם רק ארבעה קיצורי דרך שונים כדי לשפר את המראה שלהם במפעיל האפליקציות.
בנוסף להצגת קיצורי דרך במרכז האפליקציות, אפשר להשתמש בספריית השילוב של קיצורי דרך של Google כדי להציג קיצורי דרך בפלטפורמות של Google, כמו Google Assistant. הספרייה הזו תומכת בדחיפה של מספר בלתי מוגבל של קיצורי דרך דינמיים. אם אתם משתמשים בספרייה הזו כדי להוסיף מספר גדול של קיצורי דרך, מומלץ להגדיר את rank
של קיצורי הדרך שצריכים להופיע במרכזי אפליקציות נתמכים באמצעות קריאה לשיטה setRank()
.
-
הגבלת האורך של תיאור קיצור הדרך
-
השטח בתפריט שבו מוצגים קיצורי הדרך לאפליקציה במרכז האפליקציות מוגבל. אם אפשר, כדאי להגביל את האורך של התיאור הקצר של קיצור הדרך ל-10 תווים, ואת האורך של התיאור הארוך ל-25 תווים.
מידע נוסף על תוויות לקיצורי דרך סטטיים זמין במאמר בנושא התאמה אישית של ערכי מאפיינים.
מידע נוסף על קיצורי דרך דינמיים ומוצמדים זמין במאמרי העזרה בנושא setLongLabel()
וsetShortLabel()
.
-
שמירה של היסטוריית השימוש בקיצורי דרך ובפעולות
-
לכל קיצור דרך שיוצרים, כדאי לחשוב על הדרכים השונות שבהן משתמש יכול לבצע את אותה משימה ישירות באפליקציה. צריך להתקשר אל reportShortcutUsed()
בכל אחד מהמקרים האלה כדי שמרכז האפליקציות ישמור היסטוריה מדויקת של התדירות שבה משתמש מבצע את הפעולות שמייצגות את קיצורי הדרך.
-
עדכון קיצורי דרך רק אם המשמעות שלהם נשמרת
-
כשמשנים קיצורי דרך דינמיים ומוצמדים, צריך להתקשר רק אל
updateShortcuts()
כשמשנים את המידע של קיצור דרך ששומר על המשמעות שלו. אחרת, אפשר להשתמש באחת מהשיטות הבאות, בהתאם לסוג קיצור הדרך שיוצרים מחדש:
לדוגמה, אם יוצרים קיצור דרך לניווט לסופרמרקט, כדאי לעדכן את קיצור הדרך אם שם הסופרמרקט משתנה אבל המיקום שלו נשאר זהה. אבל אם המשתמש מתחיל לקנות במיקום אחר של הסופרמרקט, עדיף ליצור קיצור דרך חדש.
-
בדיקת קיצורי דרך דינמיים בכל הפעלה של האפליקציה
-
קיצורי דרך דינמיים לא נשמרים כשמשחזרים את הנתונים למכשיר חדש. לכן, מומלץ לבדוק את מספר האובייקטים שמוחזרים על ידי getDynamicShortcuts()
בכל פעם שמפעילים את האפליקציה, ולפרסם מחדש קיצורי דרך דינמיים לפי הצורך, כמו שמוצג בקטע הקוד במאמר גיבוי ושחזור.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 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)."]]