Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release
thay vì aosp-main
để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Xây dựng phụ kiện âm thanh
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Khi triển khai một phụ kiện âm thanh như tai nghe, bộ khuếch đại tai nghe, micrô, DAC/ADC hoặc đế sạc, hãy cân nhắc cách phụ kiện kết nối với thiết bị Android. Các phần sau đây mô tả các kết nối tai nghe có dây 3,5 mm, kết nối Bus nối tiếp đa năng (USB) và kết nối Bluetooth để phát trực tuyến nhạc hoặc nội dung âm thanh khác.
Âm thanh qua giắc cắm tai nghe 3,5 mm
Nhiều thiết bị Android có đầu nối tai nghe 3,5 mm ("mini").
Ngoài các tính năng đầu ra âm thanh nổi và đầu vào âm thanh đơn truyền thống, thông số kỹ thuật của tai nghe 3,5 mm xác định các chức năng và trở kháng tiêu chuẩn cho phép khả năng tương tác giữa một loạt thiết bị Android và tai nghe.
Âm thanh qua USB
Android có thể sử dụng USB ở một số chế độ:
- Phát triển. Không hỗ trợ âm thanh.
- Phụ kiện. Do Android Open Accessory (AOA) 2.0 cung cấp và có chức năng âm thanh hạn chế, như mô tả trong phần Kết nối âm thanh tuỳ chỉnh qua USB.
- Máy chủ lưu trữ. Cho phép thiết bị Android điều khiển bus USB và hoạt động với nhiều thiết bị ngoại vi dựa trên USB, bao gồm cả giao diện âm thanh. Các thiết bị triển khai chế độ máy chủ sẽ tương thích với tai nghe USB tuân theo quy cách tai nghe USB.
Âm thanh ở chế độ máy chủ lưu trữ được mô tả trong phần Âm thanh kỹ thuật số qua USB.
Âm thanh qua Bluetooth
Một phụ kiện kết nối với Android qua Bluetooth có thể sử dụng kết nối Cấu hình phân phối âm thanh nâng cao (A2DP) để truyền phát nhạc để phát. Tính năng phát âm thanh qua Bluetooth bằng A2DP được hỗ trợ trên Android 1.5 (API cấp 3) trở lên. Người dùng Android có thể kết nối với một phụ kiện hỗ trợ hồ sơ này bằng cách sử dụng phần Cài đặt > Bluetooth của hệ thống và phát nhạc trực tiếp đến phụ kiện mà không cần ứng dụng phụ.
Kể từ Android 3.0 (API cấp 11), các ứng dụng có thể vận hành kết nối A2DP bằng cách sử dụng lớp
BluetoothA2dp
. Để cung cấp một ứng dụng tuỳ chỉnh cho đầu ra đến một phụ kiện âm thanh, bạn phải sử dụng Android 3.0 trở lên.
Các bước tiếp theo
Để bắt đầu tạo một phụ kiện âm thanh sử dụng kết nối Bluetooth, hãy làm như sau:
- Chọn một nền tảng phần cứng hoặc tạo một thiết bị phần cứng có thể hỗ trợ giao tiếp Bluetooth và hồ sơ kết nối A2DP.
- Xem lại mã nguồn firmware (
<adk-src>/adk2012/board/library/ADK2/
) của ADK 2012, bao gồm ví dụ về cách triển khai phụ kiện phát âm thanh bằng kết nối Bluetooth.
Lưu ý: Mã nguồn ADK 2012 bao gồm một ngăn xếp Bluetooth nguồn mở được tạo cho chip Texas Instruments CC2564, nhưng được thiết kế để hoạt động với mọi chip Bluetooth triển khai Giao diện máy chủ/trình điều khiển (HCI) tiêu chuẩn.
MIDI qua USB và Bluetooth LE
Bạn có thể dùng cả USB và Bluetooth năng lượng thấp làm phương thức truyền tải cho giao thức MIDI. Để biết thông tin chi tiết, hãy xem phần MIDI.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# Build audio accessories\n\nWhen implementing an audio accessory such as a headset, headphone amplifier,\nmicrophone, DAC/ADC, or dock, consider how the accessory connects to Android\ndevices. The following sections describe wired 3.5 mm headset connections,\nUniversal Serial Bus (USB) connections, and Bluetooth connections for streaming\nmusic or other audio content.\n\nAudio over 3.5 mm headset connector\n-----------------------------------\n\nMany Android devices include a 3.5 mm (\"mini\") headset connector.\nIn addition to traditional stereo output and mono input features, the\n[3.5 mm headset specification](/docs/core/interaction/accessories/headset/plug-headset-spec)\ndefines standard impedances and functions that enable interoperability between\na range of Android devices and headsets.\n\nAudio over USB\n--------------\n\nAndroid can use USB in several modes:\n\n- **Development**. Does not support audio.\n- **Accessory** . Provided by Android Open Accessory (AOA) 2.0 and provides limited audio capability, as described in [Connecting custom audio over USB](/docs/core/interaction/accessories/custom#audio-over-usb).\n- **Host** . Enables the Android device to drive the USB bus and operate with a wide range of USB-based peripherals, including audio interfaces. Devices that implement host mode will be compatible with USB headsets that follow the [USB\n headset specification](/docs/core/interaction/accessories/headset/usb-headset-spec). Host mode audio is described in [USB digital audio](/docs/core/audio/usb).\n\nAudio over Bluetooth\n--------------------\n\nAn accessory that connects with Android over Bluetooth can use an Advanced\nAudio Distribution Profile (A2DP) connection to stream music for playback. Playing\naudio over Bluetooth with A2DP is supported on Android 1.5 (API Level 3) and\nhigher. An Android user can connect to an accessory that supports this profile\nusing the system Settings \\\u003e Bluetooth and play music directly to the\naccessory without a secondary application.\n\nAs of Android 3.0 (API Level 11), applications can operate an A2DP connection\nusing the\n[`BluetoothA2dp`](http://developer.android.com/reference/android/bluetooth/BluetoothA2dp.html) class. To provide a custom application for\noutput to an audio accessory, you must use Android 3.0 or higher.\n\n### Next steps\n\nTo get started building an audio accessory that uses a Bluetooth connection:\n\n- Select a hardware platform or build a hardware device that can support Bluetooth communications and the A2DP connection profile.\n- Review the ADK 2012 [firmware\n source code](http://developer.android.com/tools/adk/adk2.html#src-download) (`\u003cadk-src\u003e/adk2012/board/library/ADK2/`), which includes an example implementation of an audio playback accessory using a Bluetooth connection.\n\n**Note:** The ADK 2012 source code includes an open\nsource Bluetooth stack built for the Texas Instruments CC2564 chip, but is\ndesigned to work with any Bluetooth chip that implements a standard\nHost/Controller Interface (HCI).\n\nMIDI over USB and Bluetooth LE\n------------------------------\n\nBoth USB and Bluetooth Low Energy can be used as transports for the\n[MIDI](http://en.wikipedia.org/wiki/MIDI) protocol. For details, see\n[MIDI](/docs/core/audio/midi)."]]