ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
คำแนะนำบัญชีโทรศัพท์
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ใน Android 10 บริการแนะนำบัญชีโทรศัพท์จะอนุญาตให้แสดงคำแนะนำสำหรับบัญชีโทรศัพท์ต่อผู้ใช้เมื่อโทรออก ตัวอย่างเช่น สำหรับผู้ใช้ที่มีอุปกรณ์ที่มีซิมหลายใบและอัตราค่าโทรภายในเครือข่ายถูกกว่า บริการนี้จะระบุผู้ให้บริการของบุคคลที่รับสายก่อน จากนั้นจึงแนะนำให้ใช้ซิมในเครือข่ายเดียวกับบุคคลที่รับสาย
บริการแนะนำบัญชีโทรศัพท์เป็นบริการที่ไม่บังคับและสามารถใช้งานได้ในอุปกรณ์ที่ใช้ Android 10 ขึ้นไป
การใช้งาน
หากต้องการใช้คำแนะนำบัญชีโทรศัพท์ ให้ใช้บริการPhoneAccountSuggestionService
1 อย่างในแอปที่อยู่ใน /system/priv-app/
ระบบจะไม่ค้นหาบริการหากมีการใช้ PhoneAccountSuggestionService
มากกว่า 1 รายการ บริการต้องประกาศสิทธิ์ android.Manifest.permission.BIND_PHONE_ACCOUNT_SUGGESTION_SERVICE
เมื่อผู้ใช้โทรออกโดยไม่ได้ตั้งค่าบัญชีโทรศัพท์ขาออกเริ่มต้นหรือบัญชีโทรศัพท์ที่ต้องการสำหรับหมายเลขปลายทาง บริการโทรคมนาคมจะเชื่อมโยงกับ PhoneAccountSuggestionService
เพื่อรวบรวมข้อมูลเกี่ยวกับบัญชี เรียก onAccountSuggestionRequest(String number)
และระงับกระบวนการโทรออก
PhoneAccountSuggestionService
ต้องโทรหา
suggestPhoneAccounts(String number, List<PhoneAccountSuggestion> suggestions)
ด้วยหมายเลขที่ onAccountSuggestionRequest(String number)
แสดง
เมื่อเรียกใช้ suggestPhoneAccounts(String number, List<PhoneAccountSuggestion> suggestions)
บริการโทรคมนาคมจะแสดงรายการบัญชีโทรศัพท์ที่แนะนำ จากนั้น ตัวต่อสายต้องแสดงรายการบัญชีโทรศัพท์ที่แนะนำเพื่อให้ผู้ใช้เลือกเพื่อโทรออก
PhoneAccountSuggestion
หากต้องการแสดงคําแนะนํา ให้ใช้คลาส PhoneAccountSuggestion
เช่น หากบริการระบุว่าผู้รับใช้ผู้ให้บริการรายเดียวกับซิมในอุปกรณ์ บริการควรทำเครื่องหมายบัญชีโทรศัพท์ด้วย REASON_INTRA_CARRIER
จากนั้นระบบจะส่งข้อมูลนี้ไปยังผู้ใช้ในโปรแกรมโทร
ตัวอย่างเช่น ในกรณีที่ผู้ใช้กำหนดค่าอุปกรณ์ให้ใช้ซิมงานสำหรับรายชื่อติดต่อทั้งหมดในบัญชี Google สำหรับงาน บริการควรทำเครื่องหมายบัญชีโทรศัพท์ด้วย REASON_USER_SET
และตั้งค่า shouldAutoSelect
เป็น "จริง" เพื่ออนุญาตให้โปรแกรมโทรข้ามกล่องโต้ตอบการเลือกและโทรออกโดยใช้บัญชีโทรศัพท์โดยอัตโนมัติ
ดูข้อมูลเกี่ยวกับคำแนะนำอื่นๆ ได้ที่
PhoneAccountSuggestion
Dialer
เมื่อการโทรเข้าสู่สถานะ STATE_SELECT_PHONE_ACCOUNT
ตัวต่อสายต้องใช้ข้อมูลจาก PhoneAccountSuggestion
เพื่อจัดการ EXTRA_SUGGESTED_PHONE_ACCOUNTS
ปิดใช้บริการ
หากต้องการปรับแต่งการติดตั้งใช้งานสำหรับผู้ให้บริการบางราย คุณสามารถเปิดหรือปิดใช้บริการได้โดยใช้ setComponentEnabledSetting
ระบบจะไม่ค้นหาบริการหากปิดใช้
การติดตั้งใช้งาน UI ของระบบ
คุณอาจต้องเปลี่ยนแปลง UI ของระบบ ทั้งนี้ขึ้นอยู่กับการติดตั้งใช้งาน เช่น หากต้องการให้ผู้ใช้ระบุได้ว่าการโทรทั้งหมดไปยังรายชื่อติดต่อที่เฉพาะเจาะจงนั้นทำจากบัญชีโทรศัพท์ที่เฉพาะเจาะจง คุณต้องใช้งานขั้นตอนการตั้งค่าที่กำหนดเองและ UI การตั้งค่าสำหรับอุปกรณ์
การตรวจสอบความถูกต้อง
หากต้องการตรวจสอบการติดตั้งใช้งาน ให้ทําการทดสอบ CTS ต่อไปนี้
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา 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,["# Phone account suggestion\n\nIn Android 10, the phone account suggestion service\nallows suggestions for phone\naccounts to be shown to users when making a call. For example, for users with a\ndevice with multiple SIMs and lower rates for intra-network calls, this\nservice first identifies the callee's carrier and then suggests using the SIM on\nthe same network as the callee.\n\nThe phone account suggestion service is optional and can be implemented on\ndevices running Android 10 or higher.\n\nImplementation\n--------------\n\nTo implement phone account suggestions, implement *one*\n[`PhoneAccountSuggestionService`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/telecomm/java/android/telecom/PhoneAccountSuggestionService.java)\nservice in an app that is located in `/system/priv-app/`. The service isn't\nqueried if more than one `PhoneAccountSuggestionService`is implemented. The\nservice must declare the\n`android.Manifest.permission.BIND_PHONE_ACCOUNT_SUGGESTION_SERVICE` permission.\n\nWhen a user makes an outgoing call where neither the\n[default outgoing phone account](https://developer.android.com/reference/android/telecom/TelecomManager.html#getDefaultOutgoingPhoneAccount(java.lang.String))\nnor the\n[preferred phone account](https://developer.android.com/reference/android/provider/ContactsContract.DataColumns.html#PREFERRED_PHONE_ACCOUNT_COMPONENT_NAME)\nis set for the callee, the telecom service binds to\n`PhoneAccountSuggestionService` to gather information about the accounts,\n[`onAccountSuggestionRequest(String number)`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/telecomm/java/android/telecom/PhoneAccountSuggestionService.java#98)\nis called, and the outgoing call process is suspended.\n\n`PhoneAccountSuggestionService` must call\n[`suggestPhoneAccounts(String number, List\u003cPhoneAccountSuggestion\u003e suggestions)`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/telecomm/java/android/telecom/PhoneAccountSuggestionService.java#110)\nwith the number returned by\n[`onAccountSuggestionRequest(String number)`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/telecomm/java/android/telecom/PhoneAccountSuggestionService.java#98).\n\nWhen\n[`suggestPhoneAccounts(String number, List\u003cPhoneAccountSuggestion\u003e suggestions)`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/telecomm/java/android/telecom/PhoneAccountSuggestionService.java#110)\nis called, the telecom service returns a list of suggested phone accounts. The\ndialer must then display the list of suggested phone accounts for the user to\nchoose from to make the call.\n\n### PhoneAccountSuggestion\n\nTo make suggestions, use the\n[PhoneAccountSuggestion](https://android.googlesource.com/platform/frameworks/base/+/android16-release/telecomm/java/android/telecom/PhoneAccountSuggestion.java)\nclass.\nFor example, if the service determines the callee is on the same carrier as one\nof the SIMs in the device, the service should mark the phone account with\n[`REASON_INTRA_CARRIER`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/telecomm/java/android/telecom/PhoneAccountSuggestion.java#46).\nThis information can then be conveyed to the user in the dialer.\n\nFor example, in a situation where the user has configured the device to use\na work SIM for all contacts\nin a work Google Account, the service should mark the phone account with\n[`REASON_USER_SET`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/telecomm/java/android/telecom/PhoneAccountSuggestion.java#58)\nand set\n[`shouldAutoSelect`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/telecomm/java/android/telecom/PhoneAccountSuggestion.java#121)\nto true to allow the dialer to bypass the selection dialog and automatically\nplace the call using the phone account.\n\nFor information on other suggestions, see\n[`PhoneAccountSuggestion`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/telecomm/java/android/telecom/PhoneAccountSuggestion.java).\n\n### Dialer\n\nWhen the call enters the\n[`STATE_SELECT_PHONE_ACCOUNT`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/telecomm/java/android/telecom/Call.java#84)\nstate, the dialer must use the information from\n[`PhoneAccountSuggestion`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/telecomm/java/android/telecom/PhoneAccountSuggestion.java)\nto handle\n[`EXTRA_SUGGESTED_PHONE_ACCOUNTS`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/telecomm/java/android/telecom/Call.java#136).\n\n### Disable the service\n\nTo customize your implementation for specific carriers, you can enable or\ndisable the service using\n[`setComponentEnabledSetting`](https://developer.android.com/reference/android/content/pm/PackageManager.html#setComponentEnabledSetting(android.content.ComponentName,%20int,%20int)%60).\nThe service is not queried if disabled.\n\n### System UI implementation\n\nDepending on your implementation, changes to the system UI may be required. For\nexample, to allow users to specify that all calls to a specific contact are\nmade from a specific phone account, you must implement a customized set up flow\nand settings UI for the device.\n\nValidation\n----------\n\nTo validate your implementation, run the following CTS tests:\n\n- [`/cts/tests/tests/telecom/src/android/telecom/cts/PhoneAccountSuggestionServiceTest.java`](https://android.googlesource.com/platform/cts/+/android16-release/tests/tests/telecom/src/android/telecom/cts/PhoneAccountSuggestionServiceTest.java)\n- [`/cts/tests/tests/telecom/src/android/telecom/cts/PhoneAccountSuggestionTest.java`](https://android.googlesource.com/platform/cts/+/android16-release/tests/tests/telecom/src/android/telecom/cts/PhoneAccountSuggestionTest.java)"]]