自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
打造音響配件
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
在導入耳機、耳機擴大器、麥克風、DAC/ADC 或底座等音訊配件時,請考量配件如何連線至 Android 裝置。以下各節說明有線 3.5 毫米耳機連線、通用序列匯流格式 (USB) 連線,以及用於串流音樂或其他音訊內容的藍牙連線。
透過 3.5 公釐耳機連接器傳輸音訊
許多 Android 裝置都內建 3.5 公釐 (「迷你」) 耳機連接器。除了傳統的立體聲輸出和單聲道輸入功能,3.5 公釐耳機規格也定義了標準阻抗和功能,可在各種 Android 裝置和耳機之間提供互通性。
透過 USB 傳輸音訊
Android 可在多種模式下使用 USB:
- 開發階段。不支援音訊。
- 配件。由 Android Open Accessory (AOA) 2.0 提供,提供有限的音訊功能,如「透過 USB 連線至自訂音訊」一文所述。
- 主機:讓 Android 裝置可驅動 USB 匯流排,並與多種 USB 周邊裝置 (包括音訊介面) 搭配運作。實作主機模式的裝置,可與遵循 USB 耳機規格的 USB 耳機相容。如要瞭解主機模式音訊,請參閱「USB 數位音訊」。
藍牙音訊
透過藍牙連線至 Android 的配件可使用進階音訊分發設定檔 (A2DP) 連線,串流播放音樂。Android 1.5 (API 級別 3) 以上版本支援透過藍牙播放音訊,並使用 A2DP。Android 使用者可以透過系統的「設定」>「藍牙」連線至支援此設定檔的配件,並直接在配件上播放音樂,不必使用其他應用程式。
自 Android 3.0 (API 級別 11) 起,應用程式可使用
BluetoothA2dp
類別操作 A2DP 連線。如要提供自訂應用程式,以便將輸出內容傳送至音訊配件,您必須使用 Android 3.0 以上版本。
後續步驟
如要開始建構使用藍牙連線的音訊配件,請按照下列步驟操作:
- 選取硬體平台或建構可支援藍牙通訊和 A2DP 連線設定檔的硬體裝置。
- 請查看 ADK 2012 韌體原始碼 (
<adk-src>/adk2012/board/library/ADK2/
),其中包含使用藍牙連線的音訊播放配件的實作範例。
注意:ADTK 2012 原始碼包含為德州儀器 CC2564 晶片建構的開放原始碼藍牙堆疊,但設計用於與實作標準主機/控制器介面 (HCI) 的任何藍牙晶片搭配使用。
透過 USB 和藍牙 LE 傳輸 MIDI
USB 和 Bluetooth Low Energy 都可以用來傳輸 MIDI 通訊協定。詳情請參閱MIDI。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# 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)."]]