أفضل الممارسات للاختصارات
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
عند تصميم اختصارات تطبيقك وإنشائها، اتبع هذه الإرشادات:
-
اتّباع إرشادات التصميم
-
لجعل اختصارات تطبيقك متسقة مرئيًا مع الاختصارات المستخدمة لتطبيقات النظام، اتّبِع
إرشادات تصميم رموز اختصارات التطبيقات.
-
نشر أربعة اختصارات مختلفة فقط
-
على الرغم من أنّ واجهة برمجة التطبيقات تتيح مزيجًا من ما يصل إلى 15 اختصارًا ثابتًا وديناميكيًا لتطبيقك،
ننصحك بنشر أربعة اختصارات مختلفة فقط لتحسين مظهرها المرئي في مشغّل التطبيقات.
بالإضافة إلى عرض الاختصارات على مشغّل التطبيقات، يمكنك استخدام مكتبة اختصارات Google لدمج اختصارات Google لعرض الاختصارات على مساحات عرض Google، مثل "مساعد Google". تدعم هذه المكتبة دفع عدد غير محدود
من الاختصارات الديناميكية. إذا كنت تستخدم هذه المكتبة لإرسال عدد كبير من
الاختصارات، نقترح إعداد rank
للاختصارات التي يجب أن تظهر في مشغِّلات
التطبيقات المتوافقة من خلال استدعاء طريقة
setRank()
.
-
الحدّ من طول وصف الاختصار
-
إنّ المساحة المتوفّرة في القائمة التي تعرض اختصارات تطبيقك في مشغّل التطبيقات محدودة. عندما يكون ذلك ممكنًا،
حدد طول "الوصف القصير" للاختصار بـ 10 أحرف، واختصر طول "الوصف الطويل" بـ 25 حرفًا.
لمزيد من المعلومات حول تصنيفات الاختصارات الثابتة، اطّلِع على تخصيص قيم السمات.
للحصول على الاختصارات الديناميكية والمثبَّتة، اقرأ المستندات المرجعية على
setLongLabel()
وsetShortLabel()
.
-
الاحتفاظ بسجلّ استخدام الاختصارات والإجراءات
-
في كل اختصار تنشئه، فكِّر في الطرق المختلفة التي يمكن للمستخدم من خلالها إنجاز المهمة نفسها
مباشرةً في تطبيقك. عليك طلب
reportShortcutUsed()
في كل حالة من هذه الحالات كي يحتفظ مشغّل التطبيقات بسجلّ دقيق لعدد مرات تنفيذ المستخدم للإجراءات التي تمثل اختصاراتك.
-
تعديل الاختصارات فقط عند الاحتفاظ بمعناها
-
عند تغيير الاختصارات الديناميكية والمثبَّتة، يجب استدعاء
updateShortcuts()
فقط
عند تغيير معلومات الاختصار الذي يحتفظ بمعناه. بخلاف ذلك، استخدم إحدى
الطرق التالية، بناءً على نوع الاختصار الذي تعيد إنشاؤه:
على سبيل المثال، إذا قمت بإنشاء اختصار للانتقال إلى سوبر ماركت، من المناسب
تحديث الاختصار إذا تغير اسم السوبرماركت ولكن يظل موقعه كما هو. إذا بدأ المستخدم التسوق في موقع سوبرماركت مختلف، فمن الأفضل إنشاء اختصار جديد.
-
التحقّق من الاختصارات الديناميكية عند إطلاق تطبيقك
-
لا يتم الاحتفاظ بالاختصارات الديناميكية عندما يستعيد المستخدم بياناته على جهاز جديد. ولهذا السبب، ننصحك بالتحقق من عدد العناصر التي يعرضها
getDynamicShortcuts()
في كل مرة يتم فيها تشغيل التطبيق وإعادة نشر الاختصارات الديناميكية حسب الحاجة، كما هو موضّح في مقتطف الرمز
في صفحة
الاحتفاظ بنسخة احتياطية والاستعادة.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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)."]]