ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
การรองรับตัวแก้ไขวิธีการป้อนข้อมูล
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
การอัปเดตที่ทํากับพื้นที่เฉพาะของจอแสดงผลมีดังนี้
Android 10 รองรับแป้นพิมพ์ซอฟต์แวร์สําหรับแอปที่ทํางานบนจอแสดงผลที่ไม่ใช่ค่าเริ่มต้น
แอปที่ทำงานบนจอแสดงผลที่ไม่ใช่ค่าเริ่มต้น
จอแสดงผลที่แสดงแป้นพิมพ์ซอฟต์แวร์ของเครื่องมือแก้ไขวิธีการป้อนข้อมูล (IME) มีโหมดต่างๆ แป้นพิมพ์ซอฟต์แวร์จะแสดงในตำแหน่งต่อไปนี้
- เดียวกันกับที่แสดงแอปที่โฟกัสอยู่
- การแสดงผลเริ่มต้นขณะที่แอปที่โฟกัสทำงานอยู่บนจอแสดงผลที่ไม่ใช่ค่าเริ่มต้น
- ไม่มีการแสดงผลเลย
ระบบจะกำหนดโหมดที่จะใช้ตามการตั้งค่าของจอแสดงผลที่แอปที่โฟกัสปรากฏอยู่ ดูรายละเอียดเพิ่มเติมได้ที่
WindowManager#setDisplayImePolicy()
WindowManager#getDisplayImePolicy()

รูปที่ 1 แป้นพิมพ์ซอฟต์แวร์ IME ตามที่ปรากฏบนจอแสดงผลรอง ซึ่งรวมถึงแอปเป้าหมาย
ระบบจะใช้ IME รายการเดียว แต่สามารถสลับระหว่างจอแสดงผลเพื่อติดตามโฟกัสของผู้ใช้ Android 10 จะคาดหวังโดยอัตโนมัติว่า IME ของบุคคลที่หนึ่งและบุคคลที่สามทั้งหมดจะแก้ไขเลย์เอาต์และปรับขนาดตามขนาดการแสดงผลใหม่เมื่อสร้าง
หากมีการเชื่อมต่อที่ใช้งานอยู่ในจอแสดงผล A และช่องป้อนข้อมูลขอโฟกัสการป้อนข้อมูลในจอแสดงผล B ระบบจะดำเนินการตามขั้นตอนต่อไปนี้
- การเชื่อมต่ออินพุตใหม่มาจากช่องป้อนข้อมูลในจอแสดงผล ข.
InputMethodManagerService
จะตรวจสอบว่าควรอนุมัติการเชื่อมต่อหรือไม่
- เลือกการแสดงผลสำหรับ IME หากจอแสดงผล ข รองรับการแสดง IME และได้รับอนุญาตให้แสดง IME ระบบจะใช้ ข มิฉะนั้น ระบบจะเลือกจอแสดงผลของอุปกรณ์หลัก
- หากจอแสดงผลที่เลือกไม่ได้มาจากจอแสดงผล A ระบบจะสร้างการเชื่อมต่ออีกครั้ง
InputMethodService
ถูกทำลายแล้วสร้างอีกครั้ง
ข้อจำกัดด้านความปลอดภัย
ระบบจะไม่แสดง IME ในจอแสดงผลเสมือนที่ไม่ได้เป็นของระบบ เนื่องด้วยข้อกังวลด้านความปลอดภัยที่ว่าแอปที่เป็นอันตรายอาจสร้างจอแสดงผลเสมือนจริงที่เปิดใช้การรองรับการตกแต่งระบบ และอ่านข้อมูลที่ละเอียดอ่อนของผู้ใช้จากแพลตฟอร์ม เช่น การคาดคะเนการพิมพ์และพื้นหลังที่กำหนดเอง
การใช้งาน
ใน Android 9 (และต่ำกว่า) IME จะใช้งานได้ในหน้าจอเริ่มต้นเท่านั้น ตามที่อธิบายไว้ในวิธีการป้อนข้อมูลบนหน้าจอ ใน Android 10 (และเวอร์ชันที่ใหม่กว่า) ผู้ใช้สามารถสลับไปมาระหว่างช่องป้อนข้อความต่างๆ ในจอแสดงผลต่างๆ ได้โดยการเปลี่ยนโฟกัส และหน้าต่าง IME จะย้ายไปยังจอแสดงผลรอง
การติดตั้งใช้งานใน WindowManager
จะติดตามหน้าต่างวิธีการป้อนข้อมูล (หน้าต่าง IME ที่วาดแป้นพิมพ์บนหน้าจอ) และเป้าหมายวิธีการป้อนข้อมูล (หน้าต่างที่ป้อนข้อมูล IME) เพื่อจัดการสถานะ IME
สำหรับ InputMethodManagerService
(IMMS) ไม่มีกลไกอื่นๆ ในตัวที่นำไปเผยแพร่การเปลี่ยนแปลงการแสดงผลไปยัง InputMethodService
(IMS) และกำหนดค่าเลย์เอาต์แป้นพิมพ์ใหม่อีกครั้งเมื่อรันไทม์เมื่อย้ายโฟกัสไปยังจอแสดงผลอื่น
Android 10 ใช้สิ่งต่อไปนี้เพื่อให้หน้าต่าง IME สลับไปมาระหว่างจอแสดงผล
- ตอนนี้ระบบจะติดตาม IME และหน้าต่างเป้าหมายอินพุตต่อจอแสดงผลใน
DisplayContent#mInputMethodWindow
และ DisplayContent#mInputMethodTarget
เพื่อให้ WindowManager (WM) จัดการสถานะโฟกัส IME แยกจากแต่ละจอแสดงผลได้
- ฝั่ง IMMS เมื่อได้รับคําขอโฟกัสจากไคลเอ็นต์แอปของจอแสดงผลภายนอกผ่าน
ViewRootImpl#handleWindowFocusChanged ->
InputMethodManager#onPostWindowFocus ->
IMMS#startInputOrWindowGainedFocus
ระบบจะยกเลิกการเชื่อมโยงบริการเมธอดอินพุตปัจจุบันก่อน จากนั้นจึงเชื่อมโยงบริการอีกครั้งเพื่อแนบโทเค็นหน้าต่าง IME ใหม่สําหรับจอแสดงผลภายนอกใน onServiceConnected()
- ฝั่ง IMS หลังจากได้รับ
IMS#attachToken
แล้ว ระบบจะดำเนินการตามขั้นตอนต่อไปนี้
ContextImpl#updateDisplay
เรียกใช้เพื่ออัปเดตการแสดงผลของบริบทบริการใน InputMethodService#attachToken()
ซึ่งจะเรียกใช้ViewGroup#addView()
เพื่อแก้ไขเลย์เอาต์ของแป้นพิมพ์และปรับให้เข้ากับจอแสดงผลเป้าหมายโดยตรวจสอบบริบทปัจจุบัน
- หลังจากเรียก
DisplayContent#setInputMethodWindowLocked()
แล้ว การใช้งานจะส่งการเปลี่ยนแปลงการกำหนดค่าการแสดงผลระดับกระบวนการโดยใช้ WindowProcessController
ไปยังกระบวนการ IME เพื่อลบล้างทรัพยากรและเมตริกการแสดงผล
- ไคลเอ็นต์
InputMethodService
ได้รับการกําหนดค่าที่ถูกต้องซึ่งมีเมตริกการแสดงผลที่ถูกต้องหลังจาก onConfigurationChanged()
และเรียกใช้ ViewGroup#addView()
เพื่อเริ่มต้นใหม่มุมมองอินพุต
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา 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,["# Input method editor support\n\nUpdates made to these display-specific areas are provided below:\n\n- [Apps running on a non-default display](/docs/core/display/multi_display/ime-support#non-default)\n- [Multi-session input method editor support](/docs/core/display/multi_display/ime-support#ime-multi)\n\nAndroid 10 supports\n[software keyboard](https://developer.android.com/guide/topics/text/creating-input-method)\nfor apps running on a non-default display.\n\nApps running on a non-default display\n-------------------------------------\n\nIn terms of which display shows the software keyboard of the Input Method Editor\n(IME), there are different modes. The software keyboard is shown on the:\n\n- *Same* display on which the focused app appears.\n- *Default* display while the focused app is running on a non-default display.\n- *No* display at all.\n\nThe system determines which mode to use based on the settings of the display\non which the focused app appears. For more details, see:\n\n- `WindowManager#setDisplayImePolicy()`\n- `WindowManager#getDisplayImePolicy()`\n\n**Figure 1.** IME software keyboard as it appears on secondary display,\nincluding target app\n\nThe system uses a single IME, but can shift between displays to follow\nuser focus. Android 10 automatically expects all first- and third-party IMEs to\nrevise the layout and resize according to the new display size when created.\n\nIf there's an active connection on display A, and an input field requests\ninput focus on display B, then the following flow occurs:\n\n1. A new input connection comes from the input field on display B.\n2. `InputMethodManagerService` checks if the connection should be approved.\n3. A display is selected for the IME. If display B supports showing the IME and is allowed to show it, then B is used. Otherwise, the primary device display is selected.\n4. If the selected display is not from display A, then the connection is re-established. `InputMethodService` is destroyed and then created again.\n\n### Security restriction\n\nThe system won't show an IME on virtual displays that aren't owned by the\nsystem. This is due to a security concern that a malicious app could create a\nvirtual display with enabled\n[system decorations support](/docs/core/display/multi_display/system-decorations)\nand read user-sensitive information from the surface, such as typing predictions\nand custom backgrounds.\n\n### Implementation\n\nIn Android 9 (and lower), the IME was only available on the default screen, as\ndescribed in [On-Screen\nInput methods](https://android-developers.googleblog.com/2009/04/updating-applications-for-on-screen.html). In Android 10 (and higher), a user can switch\nbetween different input text fields on different displays by switching focus,\nand the IME window moves to the secondary displays.\n\nThe implementation in `WindowManager` tracks the input method\nwindow (the IME window where the soft keyboard is drawn) and the input method\ntarget (the window where the IME input goes) to manage the IME state.\n\nFor `InputMethodManagerService` (IMMS), no other built-in mechanism can\npropagate the display change to `InputMethodService` (IMS) and\nreconfigure the keyboard layout at runtime when moving focus to another display.\n\nTo achieve the IME window switch between displays, Android\n10 implements the following:\n\n- The IME and input target window are now tracked per display in `DisplayContent#mInputMethodWindow` and `DisplayContent#mInputMethodTarget`, so that the WindowManager (WM) can manage the IME focus state independently of each display.\n- On the IMMS side, when an app client's focus request from the external display is received through `ViewRootImpl#handleWindowFocusChanged -\u003e\n InputMethodManager#onPostWindowFocus -\u003e\n IMMS#startInputOrWindowGainedFocus`, it first unbinds the current input method service and then rebinds the service to reattach the new IME window token for the external display in `onServiceConnected()`.\n- On the IMS side, after the `IMS#attachToken` is received, the following flow occurs:\n - `ContextImpl#updateDisplay` is called to update the service context's display in `InputMethodService#attachToken()`. This calls `ViewGroup#addView()` to revise the layout of the keyboard and adapt to the target display checking the current context.\n - After `DisplayContent#setInputMethodWindowLocked()` is called, the implementation sends process-level display configuration changes using the `WindowProcessController` to IME process to override resources and display metrics.\n - The `InputMethodService` client gets the correct configuration with the correct display metrics after `onConfigurationChanged()` and the `ViewGroup#addView()` call to reinitialize the input view."]]