Bluetooth API는 블루투스 프로필 작업을 지원합니다. 가
블루투스 프로필은 블루투스 기반 무선 인터페이스 사양입니다.
기기 간 통신을 지원할 수 있어야 합니다 휴대기기의 경우
헤드셋에 연결하려면 두 기기 모두
핸즈프리 프로필
Bluetooth API는 다음과 같은 블루투스의 구현을 제공합니다.
프로필:
헤드셋 헤드셋 프로필은 블루투스 헤드셋이
좀 더 까다로워요. Android는
BluetoothHeadset 클래스
블루투스 헤드셋 서비스를 제어하기 위한 프록시입니다. 여기에는
블루투스 헤드셋과 핸즈프리 (v1.5) 프로필을 모두 지원합니다. BluetoothHeadset
클래스에는 AT 명령에 대한 지원이 포함됩니다. 이 주제에 대한 자세한 내용은
공급업체별 AT 명령어.
A2DP 고급 오디오 전송 프로필 (A2DP) 프로필은 어떻게
블루투스를 통해 한 기기에서 다른 기기로 고품질 오디오를 스트리밍할 수 있음
연결 Android는
BluetoothA2dp 클래스:
블루투스 A2DP 서비스를 제어하기 위한 프록시입니다.
의료 기기. Android는 블루투스 건강 기기 지원 제공
프로필 (HDP) 이를 통해 블루투스를 사용하여 서로 통신하는 앱을 만들 수 있습니다.
심박수 모니터, 혈압 등 블루투스를 지원하는 의료 기기 사용 시
미터, 온도계, 체중계 등입니다. 지원되는 기기 및
해당하는 기기 데이터 전문화 코드에 대해서는 블루투스 HDP를 참조하세요.
기기 데이터
전문 분야.
이 값은 ISO/IEEE 11073-20601 [7] 사양에서도 참조됩니다.
명명법 부록의 MDC_DEV_SPEC_PROFILE_*에 명시되어 있습니다. 자세한 내용은
HDP에 관한 자세한 내용은 의료 기기 프로필을 참고하세요.
프로필 프록시 객체가 있으면 이를 사용하여
연결을 설정하고 해당 프로필과 관련된 다른 작업을 수행할 수 있습니다.
다음 코드 스니펫은 BluetoothHeadset 프록시에 연결하는 방법을 보여줍니다.
개체를 사용하여 헤드셋 프로필을 제어할 수 있습니다.
Kotlin
varbluetoothHeadset:BluetoothHeadset? =null// Get the default adaptervalbluetoothAdapter:BluetoothAdapter? =BluetoothAdapter.getDefaultAdapter()privatevalprofileListener=object:BluetoothProfile.ServiceListener{overridefunonServiceConnected(profile:Int,proxy:BluetoothProfile){if(profile==BluetoothProfile.HEADSET){bluetoothHeadset=proxyasBluetoothHeadset}}overridefunonServiceDisconnected(profile:Int){if(profile==BluetoothProfile.HEADSET){bluetoothHeadset=null}}}// Establish connection to the proxy.bluetoothAdapter?.getProfileProxy(context,profileListener,BluetoothProfile.HEADSET)// ... call functions on bluetoothHeadset// Close proxy connection after use.bluetoothAdapter?.closeProfileProxy(BluetoothProfile.HEADSET,bluetoothHeadset)
자바
BluetoothHeadsetbluetoothHeadset;// Get the default adapterBluetoothAdapterbluetoothAdapter=BluetoothAdapter.getDefaultAdapter();privateBluetoothProfile.ServiceListenerprofileListener=newBluetoothProfile.ServiceListener(){publicvoidonServiceConnected(intprofile,BluetoothProfileproxy){if(profile==BluetoothProfile.HEADSET){bluetoothHeadset=(BluetoothHeadset)proxy;}}publicvoidonServiceDisconnected(intprofile){if(profile==BluetoothProfile.HEADSET){bluetoothHeadset=null;}}};// Establish connection to the proxy.bluetoothAdapter.getProfileProxy(context,profileListener,BluetoothProfile.HEADSET);// ... call functions on bluetoothHeadset// Close proxy connection after use.bluetoothAdapter.closeProfileProxy(bluetoothHeadset);
공급업체 특정 AT 명령어
앱이 사전 정의된 공급업체별 AT의 시스템 브로드캐스트를 수신하도록 등록할 수 있음
헤드셋에서 전송하는 명령 (예: Plantronics +XEVENT 명령) 예를 들어
앱이 연결된 기기의 배터리 수준을 나타내는 브로드캐스트를 수신할 수 있음
사용자에게 알리거나 필요한 다른 조치를 취할 수 있습니다. 방송 만들기
수신자는
ACTION_VENDOR_SPECIFIC_HEADSET_EVENT 드림
헤드셋에 관한 공급업체별 AT 명령어를 처리하기 위한 인텐트입니다.
Bluetooth Health API를 사용할 때 다음과 같은 주요 HDP를 이해하면 도움이 됩니다.
개념:
소스
체중 체중계, 혈당 측정기, 체온계와 같은 건강 관리 기기
Android 휴대전화 또는 태블릿과 같은 스마트 기기로 의료 데이터를 전송함
싱크
의료 데이터를 수신하는 스마트 기기입니다. HDP 앱에서
싱크는 BluetoothHealthAppConfiguration 객체로 표현됩니다.
등록
특정 상태와 통신하기 위해 싱크를 등록하는 데 사용되는 프로세스
합니다
연결
의료 기기 (출처)와 의료진 간의 채널을 여는 데 사용되는 프로세스
스마트 기기 (싱크)
HDP 앱 만들기
다음은 HDP 앱을 만드는 기본 단계입니다.
BluetoothHealth 프록시 객체에 대한 참조를 가져옵니다. 일반적인
헤드셋 및 A2DP 프로필 기기를 사용하려면 getProfileProxy()를
BluetoothProfile.ServiceListener 및
HEALTH 프로필 유형
프로필 프록시 객체와의 연결을 설정합니다.
BluetoothHealthCallback 만들기 및 앱 구성 등록
(BluetoothHealthAppConfiguration)입니다.
의료 기기 연결을 설정합니다.
의료 기기에 성공적으로 연결되면 상태 읽기 및 쓰기
할 수 있습니다. 수신된 데이터는
IEEE 11073
사양을 참조하세요.
완료되면 건강 채널을 닫고 앱을 등록 취소합니다. 채널 또한
확장된 비활성이 있으면 닫힙니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[null,null,["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Bluetooth profiles\n\nThe Bluetooth API includes support for working with Bluetooth profiles. A\nBluetooth profile is a wireless interface specification for Bluetooth-based\ncommunication between devices, such as the Hands-Free profile. For a mobile\ndevice to connect to a wireless headset, both devices must support the\nHands-Free profile.\n\nThe Bluetooth API provides implementations for the following Bluetooth\nprofiles:\n\n- **Headset** . The Headset profile provides support for Bluetooth headsets to be used with mobile phones. Android provides the [`BluetoothHeadset`](/reference/android/bluetooth/BluetoothHeadset) class, which is a proxy for controlling the Bluetooth Headset Service. This includes both Bluetooth Headset and Hands-Free (v1.5) profiles. The `BluetoothHeadset` class includes support for AT commands. For more on this topic, see [Vendor-specific AT commands](#at-commands).\n- **A2DP** . The Advanced Audio Distribution Profile (A2DP) profile defines how high-quality audio can be streamed from one device to another over a Bluetooth connection. Android provides the [`BluetoothA2dp`](/reference/android/bluetooth/BluetoothA2dp) class, which is a proxy for controlling the Bluetooth A2DP Service.\n- **Health Device** . Android provides support for the Bluetooth Health Device Profile (HDP). This lets you create apps that use Bluetooth to communicate with health devices that support Bluetooth, such as heart-rate monitors, blood meters, thermometers, scales, and so on. For a list of supported devices and their corresponding device data specialization codes, see [Bluetooth's HDP\n Device Data\n Specializations](https://www.bluetooth.com/specifications/assigned-numbers/health-device-profile). These values are also referenced in the ISO/IEEE 11073-20601 \\[7\\] specification as `MDC_DEV_SPEC_PROFILE_*` in the Nomenclature Codes Annex. For more information about HDP, see [Health Device Profile](#health-profile).\n\nHere are the basic steps for working with a profile:\n\n1. Get the default adapter, as described in [Bluetooth setup](/develop/connectivity/bluetooth/setup).\n2. Set up a [`BluetoothProfile.ServiceListener`](/reference/android/bluetooth/BluetoothProfile.ServiceListener). This listener notifies [`BluetoothProfile`](/reference/android/bluetooth/BluetoothProfile) clients when they have been connected to or disconnected from the service.\n3. Use [`getProfileProxy()`](/reference/android/bluetooth/BluetoothAdapter#getProfileProxy(android.content.Context,%20android.bluetooth.BluetoothProfile.ServiceListener,%20int)) to establish a connection to the profile proxy object associated with the profile. In the following example, the profile proxy object is an instance of `BluetoothHeadset`.\n4. In [`onServiceConnected()`](/reference/android/bluetooth/BluetoothProfile.ServiceListener#onServiceConnected(int,%20android.bluetooth.BluetoothProfile)), get a handle to the profile proxy object.\n5. Once you have the profile proxy object, use it to monitor the state of the connection and perform other operations that are relevant to that profile.\n\nThe following code snippet shows how to connect to a `BluetoothHeadset` proxy\nobject so that you can control the Headset profile: \n\n### Kotlin\n\n```kotlin\nvar bluetoothHeadset: BluetoothHeadset? = null\n\n// Get the default adapter\nval bluetoothAdapter: BluetoothAdapter? = BluetoothAdapter.getDefaultAdapter()\n\nprivate val profileListener = object : BluetoothProfile.ServiceListener {\n\n override fun onServiceConnected(profile: Int, proxy: BluetoothProfile) {\n if (profile == BluetoothProfile.HEADSET) {\n bluetoothHeadset = proxy as BluetoothHeadset\n }\n }\n\n override fun onServiceDisconnected(profile: Int) {\n if (profile == BluetoothProfile.HEADSET) {\n bluetoothHeadset = null\n }\n }\n}\n\n// Establish connection to the proxy.\nbluetoothAdapter?.getProfileProxy(context, profileListener, BluetoothProfile.HEADSET)\n\n// ... call functions on bluetoothHeadset\n\n// Close proxy connection after use.\nbluetoothAdapter?.closeProfileProxy(BluetoothProfile.HEADSET, bluetoothHeadset)\n```\n\n### Java\n\n```java\nBluetoothHeadset bluetoothHeadset;\n\n// Get the default adapter\nBluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();\n\nprivate BluetoothProfile.ServiceListener profileListener = new BluetoothProfile.ServiceListener() {\n public void onServiceConnected(int profile, BluetoothProfile proxy) {\n if (profile == BluetoothProfile.HEADSET) {\n bluetoothHeadset = (BluetoothHeadset) proxy;\n }\n }\n public void onServiceDisconnected(int profile) {\n if (profile == BluetoothProfile.HEADSET) {\n bluetoothHeadset = null;\n }\n }\n};\n\n// Establish connection to the proxy.\nbluetoothAdapter.getProfileProxy(context, profileListener, BluetoothProfile.HEADSET);\n\n// ... call functions on bluetoothHeadset\n\n// Close proxy connection after use.\nbluetoothAdapter.closeProfileProxy(bluetoothHeadset);\n```\n\n### Vendor-specific AT commands\n\nApps can register to receive system broadcasts of predefined vendor-specific AT\ncommands sent by headsets (such as a Plantronics +XEVENT command). For example,\nan app could receive broadcasts that indicate a connected device's battery level\nand could notify the user or take other action as needed. Create a broadcast\nreceiver for the\n[`ACTION_VENDOR_SPECIFIC_HEADSET_EVENT`](/reference/android/bluetooth/BluetoothHeadset#ACTION_VENDOR_SPECIFIC_HEADSET_EVENT)\nintent to handle vendor-specific AT commands for the headset.\n\nHealth Device Profile\n---------------------\n\nAndroid supports the Bluetooth Health Device Profile (HDP). The Bluetooth Health\nAPI includes the classes\n[`BluetoothHealth`](/reference/android/bluetooth/BluetoothHealth),\n[`BluetoothHealthCallback`](/reference/android/bluetooth/BluetoothHealthCallback),\nand\n[`BluetoothHealthAppConfiguration`](/reference/android/bluetooth/BluetoothHealthAppConfiguration),\nwhich are described in [Key classes and\ninterfaces](/develop/connectivity/bluetooth#key-classes).\n| **Caution:** The Health Device Profile (HDP) and MCAP protocols are no longer used. New apps should use Bluetooth Low Energy based solutions such as [`BluetoothGatt`](/reference/android/bluetooth/BluetoothGatt), [`BluetoothAdapter.listenUsingL2capChannel()`](/reference/android/bluetooth/BluetoothAdapter#listenUsingL2capChannel()), or [`BluetoothDevice#createL2capChannel(int)`](/reference/android/bluetooth/BluetoothDevice#createL2capChannel(int)).\n\nWhen using the Bluetooth Health API, it's helpful to understand these key HDP\nconcepts:\n\nSource\n: A health device, such as a weight scale, glucose meter, or thermometer, which\n transmits medical data to a smart device, such as an Android phone or tablet.\n\nSink\n: The smart device that receives the medical data. In an HDP app, the\n sink is represented by a `BluetoothHealthAppConfiguration` object.\n\nRegistration\n: The process used to register a sink for communicating with a particular health\n device.\n\nConnection\n: The process used to open a channel between a health device (source) and a\n smart device (sink).\n\n### Create an HDP app\n\nHere are the basic steps involved in creating an HDP app:\n\n1. Get a reference to the `BluetoothHealth` proxy object. As with regular\n headset and A2DP profile devices, you must call `getProfileProxy()` with a\n `BluetoothProfile.ServiceListener` and the\n [`HEALTH`](/reference/android/bluetooth/BluetoothProfile#HEALTH) profile type\n to establish a connection with the profile proxy object.\n\n2. Create a `BluetoothHealthCallback` and register an app configuration\n (`BluetoothHealthAppConfiguration`) that acts as a health sink.\n\n3. Establish a connection to a health device.\n\n | **Note:** Some devices initiate the connection automatically. It is unnecessary to carry out this step for those devices.\n4. When connected successfully to a health device, read and write to the health\n device using the file descriptor. The received data needs to be interpreted\n using a health manager, which implements the [IEEE 11073\n specifications](https://standards.ieee.org/standard/11073-10207-2017.html).\n\n5. When done, close the health channel and unregister the app. The channel also\n closes when there is extended inactivity."]]