دمج الملء التلقائي مع أدوات IME وخدمات الملء التلقائي
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
بدءًا من نظام التشغيل Android 11، يمكن للوحات المفاتيح وبرامج تحرير طرق الإدخال الأخرى
(IME) عرض اقتراحات الملء التلقائي بشكل مضمّن، أو في شريط اقتراحات، أو بشكل مشابه بدلاً من أن يعرض النظام الاقتراحات في قائمة. بما أنّ اقتراحات الملء التلقائي هذه يمكن أن تحتوي على بيانات خاصة، مثل كلمات المرور أو معلومات بطاقة الائتمان، يتم إخفاء الاقتراحات عن محرر أسلوب الإدخال إلى أن يختار المستخدم أحدها. يجب تحديث طرق الإدخال وميزات الملء التلقائي، مثل خدمات إدارة كلمات المرور، للاستفادة من هذه الميزة. إذا لم يكن محرّك IME أو خدمة الملء التلقائي يتيح الملء التلقائي المضمّن، ستظهر الاقتراحات في قائمة، كما هو الحال في الإصدارات الأقدم من Android 11.
سير العمل
في هذا المسار، يشير مصطلح محرّر أسلوب الإدخال إلى لوحة المفاتيح الحالية أو أي محرّر إدخال آخر، ويشير مصطلح مقدّم الاقتراحات إلى مقدّم الاقتراحات المناسب لخدمة الملء التلقائي.
استنادًا إلى حقل الإدخال وإعدادات المستخدم، قد يكون مقدّم الاقتراحات هو المنصة أو خدمة التعبئة التلقائية.
يركّز المستخدم على حقل إدخال يؤدي إلى تشغيل ميزة "الملء التلقائي"، مثل حقل إدخال كلمة المرور أو بطاقة الائتمان.
يطلب النظام الأساسي من محرّك طريقة الإدخال الحالي ومقدّم اقتراحات الإكمال التلقائي المناسب
معرفة ما إذا كانا يتيحان ميزة "الإكمال التلقائي المضمّن". إذا كان محرّك IME أو مزوّد الاقتراحات لا يتيح ميزة "الملء التلقائي المضمّن"، سيظهر الاقتراح في قائمة، كما هو الحال في الإصدار 10 من نظام التشغيل Android والإصدارات الأقدم.
تطلب المنصة من محرر أسلوب الإدخال تقديم طلب اقتراح. يحدّد طلب الاقتراح هذا الحدّ الأقصى لعدد الاقتراحات التي سيتم عرضها، كما يوفّر مواصفات العرض لكل اقتراح. تحدّد مواصفات العرض التقديمي أشياء مثل الحد الأقصى للحجم وحجم النص والألوان وبيانات الخط، ما يتيح لمقدّم الاقتراحات مطابقة شكل وأسلوب طريقة الإدخال.
تطلب المنصة من مقدّم الاقتراحات تقديم ما يصل إلى عدد الاقتراحات المطلوب. يتضمّن كل اقتراح دالة رد الاتصال لتوسيع View الذي يحتوي على واجهة المستخدم الخاصة بالاقتراح.
تُعلم المنصة طريقة الإدخال IME بأنّ الاقتراحات جاهزة. تعرض طريقة الإدخال IME الاقتراحات من خلال استدعاء طريقة رد الاتصال لتوسيع كل View خاص بالاقتراح. لحماية المعلومات الخاصة بالمستخدم، لا ترى طريقة الإدخال هذه الاقتراحات في هذه المرحلة.
إذا اختار المستخدم أحد الاقتراحات، يتم إعلام طريقة الإدخال بنفس الطريقة كما لو أنّ المستخدم اختار اقتراحًا من قائمة النظام.
توضّح الأقسام التالية كيفية ضبط طريقة الإدخال أو خدمة الملء التلقائي لتتيح الملء التلقائي المضمّن.
ضبط طرق الإدخال (IME) لتفعيل ميزة "الملء التلقائي المضمّن"
يوضّح هذا القسم كيفية ضبط طريقة الإدخال (IME) لتتيح التعبئة التلقائية المضمّنة. إذا كان محرر أسلوب الإدخال (IME) لا يتيح ميزة الملء التلقائي المضمّن، ستعرض المنصة تلقائيًا اقتراحات الملء التلقائي في قائمة.
ضبط إعدادات خدمات الملء التلقائي لتفعيل ميزة "الملء التلقائي المضمّن"
يوضّح هذا القسم كيفية ضبط خدمة الملء التلقائي لتتيح الملء التلقائي المضمّن. إذا كان تطبيقك لا يتيح ميزة "الملء التلقائي المضمّن"، ستعرض المنصة اقتراحات الملء التلقائي في قائمة بشكل تلقائي.
عندما تحتاج طريقة الإدخال إلى اقتراحات الملء التلقائي، تستدعي المنصة طريقة onFillRequest() في خدمة الملء التلقائي، تمامًا كما تفعل في الإصدارات الأقدم من Android 11. ومع ذلك، يجب أن تستدعي خدمتك طريقة getInlineSuggestionsRequest() الخاصة بالكائن FillRequest الذي تم تمريره للحصول على InlineSuggestionsRequest الذي أنشأته طريقة الإدخال. تحدّد السمة
InlineSuggestionsRequest عدد الاقتراحات المضمّنة المطلوبة
وكيفية عرض كل اقتراح. إذا لم تكن طريقة الإدخال (IME) تتيح الاقتراحات المضمّنة، ستعرض الطريقة null.
تنشئ خدمة الملء التلقائي عناصر
InlinePresentation، يصل عددها إلى الحد الأقصى المطلوب في InlineSuggestionsRequest.
يجب أن تلتزم العروض التقديمية بقيود الحجم التي يحدّدها
InlineSuggestionsRequest. لإعادة اقتراحاتك إلى محرر طريقة الإدخال، اتّصِل بالدالة
Dataset.Builder.setValue()
مرة واحدة لكل اقتراح. يوفّر نظام التشغيل Android 11 إصدارات من
Dataset.Builder.setValue() لدعم الاقتراحات المضمّنة.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-08-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-08-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["Beginning in Android 11, keyboards and other input-method editors\n(*IMEs* ) can display autofill suggestions inline, in a suggestion strip, or\nsomething similar instead of the system displaying suggestions in a menu. Since\nthese autofill suggestions can contain private data, such as passwords or\ncredit-card information, the suggestions are hidden from the IME until the user\nselects one. Update IMEs and autofill services, such as password managers, to\nmake use of this feature. If an IME or a autofill service doesn't support inline\nautofill, suggestions are shown in a menu, as in [versions earlier than\nAndroid 11](/guide/topics/text/autofill#guides).\n\nWorkflow\n\nIn this flow, *IME* means the current keyboard or other input editor, and\n*suggestion provider* means the appropriate provider of the autofill suggestion.\nDepending on the input field and the user's settings, the suggestion provider\nmight be the platform or an autofill service.\n\n1. The user focuses on an input field that triggers autofill, like a password or\n credit-card input field.\n\n2. The platform queries the current IME and the appropriate suggestion provider\n to see whether they support inline autofill. If either the IME or the\n suggestion provider doesn't support inline autofill, the suggestion is shown\n in a menu, as on Android 10 and lower.\n\n3. The platform asks the IME to provide a *suggestion request* . This suggestion\n request specifies the maximum number of suggestions to be displayed and also\n provides *presentation specs* for each suggestion. The presentation specs\n specify things like maximum size, text size, colors, and font data, letting\n the suggestion provider match the look and feel of the IME.\n\n4. The platform asks the suggestion provider to provide up to the requested\n number of suggestions. Each suggestion includes a callback to inflate a\n `View` containing the suggestion's UI.\n\n5. The platform informs the IME that suggestions are ready. The IME displays\n the suggestions by calling the callback method to inflate each suggestion's\n `View`. To protect the user's private information, the IME does *not* see\n what the suggestions are at this stage.\n\n6. If the user selects one of the suggestions, the IME is informed the same way\n as if the user picks a suggestion from a system menu.\n\nThe following sections describe how to configure your IME or autofill service to\nsupport inline autofill.\n\nConfigure IMEs to support inline autofill\n\nThis section describes how to configure your IME to support inline autofill. If\nyour IME doesn't support inline autofill, the platform defaults to showing\nautofill suggestions in a menu.\n\nYour IME must [set the `supportsInlinedSuggestions` attribute to\n`true`](/guide/topics/text/creating-input-method): \n\n \u003cinput-method\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:supportsInlineSuggestions=\"true\"/\u003e\n\nWhen the platform needs an autofill suggestion, it calls your IME's\n[`InputMethodService.onCreateInlineSuggestionsRequest()`](/reference/android/inputmethodservice/InputMethodService#onCreateInlineSuggestionsRequest(android.os.Bundle))\nmethod. You must implement this method. Return an\n[`InlineSuggestionsRequest`](/reference/android/view/inputmethod/InlineSuggestionsRequest)\nspecifying the following:\n\n- How many suggestions your IME wants.\n- An\n [`InlinePresentationSpec`](/reference/android/widget/inline/InlinePresentationSpec)\n for each suggestion, defining how the suggestion must be presented.\n\n | **Note:** If you provide fewer presentation specs than the number of suggestions requested, the last spec is used for all the excess suggestions. This means, for example, that if you provide only a single presentation spec, the suggestion provider uses that spec for all the suggestions.\n\nWhen the platform has suggestions, it calls your IME's\n[`onInlineSuggestionsResponse()`](/reference/android/inputmethodservice/InputMethodService#onInlineSuggestionsResponse(android.view.inputmethod.InlineSuggestionsResponse))\nmethod, passing an\n[`InlineSuggestionsResponse`](/reference/android/view/inputmethod/InlineSuggestionsResponse)\ncontaining the suggestions. You must implement this method. In your\nimplementation, call\n[`InlineSuggestionsResponse.getInlineSuggestions()`](/reference/android/view/inputmethod/InlineSuggestionsResponse#getInlineSuggestions())\nto get the list of suggestions, then inflate each suggestion by calling its\n[`InlineSuggestion.inflate()`](/reference/android/view/inputmethod/InlineSuggestion#inflate(android.content.Context,%20android.util.Size,%20java.util.concurrent.Executor,%20java.util.function.Consumer%3Candroid.widget.inline.InlineContentView%3E))\nmethod.\n\nConfigure autofill services to support inline autofill\n\nThis section describes how to configure your autofill service to support inline\nautofill. If your app doesn't support inline autofill, the platform defaults to\nshowing its autofill suggestions in a menu.\n\nYour autofill service must [set the `supportsInlinedSuggestions` attribute to\n`true`](/guide/topics/text/autofill-services): \n\n \u003cautofill-service\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:supportsInlineSuggestions=\"true\"/\u003e\n\nWhen the IME needs autofill suggestions, the platform calls your autofill\nservice's\n[`onFillRequest()`](/reference/android/service/autofill/AutofillService#onFillRequest(android.service.autofill.FillRequest,%20android.os.CancellationSignal,%20android.service.autofill.FillCallback))\nmethod, just as it does in versions below Android 11. However, your\nservice must call the passed `FillRequest` object's\n[`getInlineSuggestionsRequest()`](/reference/android/service/autofill/FillRequest#getInlineSuggestionsRequest())\nmethod to get the `InlineSuggestionsRequest` created by the IME. The\n`InlineSuggestionsRequest` specifies how many inline suggestions are needed and\nhow each one must be presented. If the IME doesn't support inline suggestions,\nthe method returns `null`.\n\nYour autofill service creates\n[`InlinePresentation`](/reference/android/service/autofill/InlinePresentation)\nobjects, up to the maximum number requested in the `InlineSuggestionsRequest`.\nYour presentations must obey the size constraints specified by the\n`InlineSuggestionsRequest`. To return your suggestions to the IME, call\n[`Dataset.Builder.setValue()`](/reference/android/service/autofill/Dataset.Builder#setValue(android.view.autofill.AutofillId,%20android.view.autofill.AutofillValue,%20java.util.regex.Pattern,%20android.widget.RemoteViews,%20android.service.autofill.InlinePresentation))\nonce for each suggestion. Android 11 provides versions of\n`Dataset.Builder.setValue()` to support inline suggestions.\n| **Note:** Although the IME is supposed to use the suggestions your service provides, this function isn't guaranteed."]]