블루투스 개요
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Android 플랫폼에는 블루투스 네트워크 스택 지원 기능이 포함되어 있어 기기가 다른 블루투스 기기와 무선으로 데이터를 교환할 수 있습니다. 앱 프레임워크는 블루투스 API를 통해 블루투스 기능에 액세스할 수 있는 권한을 제공합니다. 이러한 API를 통해 앱은 다른 블루투스 기기에 연결하여 지점 간 무선 기능 및 멀티 포인트 무선 기능을 사용할 수 있습니다.
블루투스 API를 사용하여 앱은 다음 작업을 할 수 있습니다.
- 다른 Bluetooth 기기를 검색합니다.
- 페어링된 블루투스 기기의 로컬 블루투스 어댑터를 쿼리합니다.
- RFCOMM 채널을 설정합니다.
- 서비스 검색을 통해 다른 기기에 연결
- 다른 기기와 데이터를 주고받습니다.
- 여러 연결을 관리합니다.
이번 주제에서는 기본 블루투스에 중점을 둡니다. 기본 블루투스는 기기 간 스트리밍 및 통신 등 배터리를 많이 사용하는 작업에 적합합니다. 저전력 요구사항이 있는 블루투스 기기의 경우 저전력 블루투스 연결을 사용하는 것이 좋습니다.
이 문서에서는 다양한 블루투스 프로필을 설명하고 블루투스 API를 사용하여 블루투스를 사용하여 통신하는 데 필요한 네 가지 주요 작업을 실행하는 방법을 설명합니다.
- Bluetooth를 설정하는 중입니다.
- 근처에 페어링되었거나 사용 가능한 기기를 찾습니다.
- 기기 연결.
- 기기 간 데이터 전송
블루투스 API 사용 데모는 블루투스 채팅 샘플 앱을 참고하세요.
기본사항
블루투스 지원 기기가 서로 데이터를 전송하려면 먼저 페어링 프로세스를 사용하여 통신 채널을 형성해야 합니다. 한 기기는 검색 가능한 기기가 수신되는 연결 요청에 사용할 수 있게 됩니다.
다른 기기가 서비스 검색 프로세스를 사용하여 검색 가능한 기기를 찾습니다.
검색 가능한 기기가 페어링 요청을 수락하면 두 기기가 보안 키를 교환하는 결합 프로세스를 완료합니다. 기기는 나중에 사용할 수 있도록 이러한 키를 캐시합니다. 페어링 및 결합 프로세스가 완료되면 두 기기가 정보를 교환합니다. 세션이 완료되면 페어링 요청을 시작한 기기가 검색 가능한 기기에 연결한 채널을 해제합니다. 그러나 두 기기는 연결된 상태로 유지되므로 서로의 범위 내에 있고 두 기기 모두 연결을 삭제하지 않은 경우 향후 세션 중에 자동으로 다시 연결할 수 있습니다.
블루투스 API를 사용하려면 매니페스트 파일에서 여러 권한을 선언해야 합니다. 앱에서 블루투스를 사용할 권한이 있으면 앱은 BluetoothAdapter
에 액세스하여 기기에서 블루투스를 사용할 수 있는지 확인해야 합니다.
Bluetooth를 사용할 수 있는 경우, 연결하려면 다음 세 단계를 따르세요.
특정 기기는 제공하는 데이터를 선언하는 특정 블루투스 프로필을 사용합니다.
기준 클래스와 인터페이스
모든 블루투스 API는 android.bluetooth
패키지에서 사용할 수 있습니다.
블루투스 연결을 만드는 데 필요한 클래스와 인터페이스는 다음과 같습니다.
BluetoothAdapter
- 로컬 블루투스 어댑터 (블루투스 라디오)를 나타냅니다.
BluetoothAdapter
는 모든 블루투스 상호작용의 진입점입니다. 이를 통해 다른 블루투스 기기를 검색하고, 연결된(페어링된) 기기 목록을 쿼리하고, 알려진 MAC 주소를 사용하여 BluetoothDevice
를 인스턴스화하고, 다른 기기의 통신을 수신 대기하는 BluetoothServerSocket
를 만들 수 있습니다.
BluetoothDevice
- 원격 블루투스 기기를 나타냅니다.
BluetoothSocket
를 통해 원격 기기와의 연결을 요청하거나 이름, 주소, 클래스, 결합 상태와 같은 기기 정보를 쿼리하는 데 사용합니다.
BluetoothSocket
- 블루투스 소켓 (TCP
Socket
와 유사함)의 인터페이스를 나타냅니다. 이는 앱이 InputStream
및 OutputStream
를 사용하여 다른 블루투스 기기와 데이터를 교환할 수 있게 하는 연결 지점입니다.
BluetoothServerSocket
- 수신 요청을 수신 대기하는 열린 서버 소켓 (TCP
ServerSocket
와 유사)을 나타냅니다. 두 기기를 연결하려면 한 기기가 이 클래스를 사용하여 서버 소켓을 열어야 합니다. 원격 블루투스 기기가 이 기기로 연결을 요청하면 해당 기기는 연결을 수락한 다음 연결된 BluetoothSocket
를 반환합니다.
BluetoothClass
- 블루투스 기기의 일반적인 특징과 기능을 설명합니다.
이는 기기의 클래스와 서비스를 정의하는 읽기 전용 속성 집합입니다. 이 정보는 기기 유형과 관련된 유용한 힌트를 제공하지만, 이 클래스의 속성이 기기에서 지원하는 모든 블루투스 프로필과 서비스를 설명하지는 않을 수도 있습니다.
BluetoothProfile
- 블루투스 프로필을 나타내는 인터페이스입니다. 블루투스 프로필은 기기 간의 블루투스 기반 통신을 위한 무선 인터페이스 사양입니다. 일례로 Hands-Free 프로필이 있습니다. 프로필에 관한 자세한 내용은 블루투스 프로필을 참고하세요.
BluetoothHeadset
- 블루투스 헤드셋을 휴대전화와 함께 사용할 수 있도록 지원합니다. 여기에는 블루투스 헤드셋 프로필과 핸즈프리 (v1.5) 프로필이 모두 포함됩니다.
BluetoothA2dp
- 고급 오디오 배포 프로필 (A2DP)을 사용하여 블루투스 연결을 통해 한 기기에서 다른 기기로 고품질 오디오를 스트리밍할 수 있는 방법을 정의합니다.
BluetoothHealth
- 블루투스 서비스를 제어하는 의료 기기 프로필 프록시를 나타냅니다.
BluetoothHealthCallback
BluetoothHealth
콜백을 구현하는 데 사용하는 추상 클래스입니다. 앱 등록 상태 및 블루투스 채널 상태의 변경사항에 관한 업데이트를 수신하려면 이 클래스를 확장하고 콜백 메서드를 구현해야 합니다.
BluetoothHealthAppConfiguration
- Bluetooth Health 서드 파티 앱이 원격 블루투스 의료 기기와 통신하기 위해 등록하는 앱 구성을 나타냅니다.
BluetoothProfile.ServiceListener
- 특정 프로필을 실행하는 내부 서비스에 연결되었거나 연결 해제되었을 때
BluetoothProfile
IPC (프로세스 간 통신) 클라이언트에 알리는 인터페이스입니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-26(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-26(UTC)"],[],[],null,["# Bluetooth overview\n\nThe Android platform includes support for the Bluetooth network stack, which\nallows a device to wirelessly exchange data with other Bluetooth devices. The\napp framework provides access to the Bluetooth functionality through Bluetooth\nAPIs. These APIs let apps connect to other Bluetooth devices, enabling\npoint-to-point and multipoint wireless features.\n\nUsing the Bluetooth APIs, an app can perform the following:\n\n- Scan for other Bluetooth devices.\n- Query the local Bluetooth adapter for paired Bluetooth devices.\n- Establish RFCOMM channels.\n- Connect to other devices through service discovery.\n- Transfer data to and from other devices.\n- Manage multiple connections.\n\nThis topic focuses on *Classic Bluetooth* . Classic Bluetooth is the right choice\nfor more battery-intensive operations, which include streaming and communicating\nbetween devices. For Bluetooth devices with low power requirements, consider\nusing [Bluetooth Low Energy](/develop/connectivity/bluetooth/ble-overview)\nconnections.\n\nThis documentation describes different Bluetooth\n[profiles](/develop/connectivity/bluetooth/profiles) and explains how to\nuse the Bluetooth APIs to accomplish the four major tasks necessary to\ncommunicate using Bluetooth:\n\n- Setting up Bluetooth.\n- Finding devices that are either paired or available in the local area.\n- Connecting devices.\n- Transferring data between devices.\n\nFor a demonstration of using the Bluetooth APIs, see the [Bluetooth Chat sample\napp](https://github.com/android/connectivity-samples/tree/master/BluetoothChat).\n\nThe basics\n----------\n\nFor Bluetooth-enabled devices to transmit data between each other, they must\nfirst form a channel of communication using a pairing process. One device, a\ndiscoverable device, makes itself available for incoming connection requests.\nAnother device finds the discoverable device using a service discovery process.\nAfter the discoverable device accepts the pairing request, the two devices\ncomplete a bonding process in which they exchange security keys. The devices\ncache these keys for later use. After the pairing and bonding processes are\ncomplete, the two devices exchange information. When the session is complete,\nthe device that initiated the pairing request releases the channel that had\nlinked it to the discoverable device. The two devices remain bonded, however, so\nthey can reconnect automatically during a future session as long as they're in\nrange of each other and neither device has removed the bond.\n\nUse of the Bluetooth APIs requires\n[declaring several permissions](/develop/connectivity/bluetooth/bt-permissions#declare)\nin your manifest file. Once your app has permission to use Bluetooth, your app\nneeds to access the\n[`BluetoothAdapter`](/reference/android/bluetooth/BluetoothAdapter) and\n[determine if Bluetooth is available on the device](/develop/connectivity/bluetooth/setup).\nIf Bluetooth is available, there are three steps to make a connection:\n\n- [Find nearby Bluetooth\n devices](/develop/connectivity/bluetooth/find-bluetooth-devices), either devices that are already paired or new ones.\n- [Connect to a Bluetooth\n device](/develop/connectivity/bluetooth/connect-bluetooth-devices).\n- [Transfer data with the connected\n device](/develop/connectivity/bluetooth/transfer-data).\n\nCertain devices use a specific [Bluetooth\nprofile](/develop/connectivity/bluetooth/profiles) that declares the data\nit provides.\n\nKey classes and interfaces\n--------------------------\n\nAll of the Bluetooth APIs are available in the\n[`android.bluetooth`](/reference/android/bluetooth/package-summary) package.\nThe following are the classes and interfaces you need in order to create\nBluetooth connections:\n\n[`BluetoothAdapter`](/reference/android/bluetooth/BluetoothAdapter)\n: Represents the local Bluetooth adapter (Bluetooth radio). The\n `BluetoothAdapter` is the entry-point for all Bluetooth interaction. Using\n this, you can discover other Bluetooth devices, query a list of bonded\n (paired) devices, instantiate a\n `BluetoothDevice` using a known MAC address, and create a\n `BluetoothServerSocket` to listen for communications from other devices.\n\n[`BluetoothDevice`](/reference/android/bluetooth/BluetoothDevice)\n: Represents a remote Bluetooth device. Use this to request a connection with a\n remote device through a `BluetoothSocket` or query information about the\n device such as its name, address, class, and bonding state.\n\n[`BluetoothSocket`](/reference/android/bluetooth/BluetoothSocket)\n: Represents the interface for a Bluetooth socket (similar to a TCP\n [`Socket`](/reference/java/net/Socket)). This is the connection point that\n allows an app to exchange data with another Bluetooth device using\n [`InputStream`](/reference/java/io/InputStream) and\n [`OutputStream`](/reference/java/io/OutputStream).\n\n[`BluetoothServerSocket`](/reference/android/bluetooth/BluetoothServerSocket)\n: Represents an open server socket that listens for incoming requests (similar\n to a TCP [`ServerSocket`](/reference/java/net/ServerSocket)). In order to\n connect two devices, one device must open a server socket with this\n class. When a remote Bluetooth device makes a connection request to this\n device, the device accepts the connection and then returns a connected\n `BluetoothSocket`.\n\n[`BluetoothClass`](/reference/android/bluetooth/BluetoothClass)\n: Describes the general characteristics and capabilities of a Bluetooth device.\n This is a read-only set of properties that defines the device's classes and\n services. Although this information provides a useful hint regarding a\n device's type, the attributes of this class don't necessarily describe all\n Bluetooth profiles and services that the device supports.\n\n[`BluetoothProfile`](/reference/android/bluetooth/BluetoothProfile)\n: An interface that represents a Bluetooth profile. A Bluetooth profile is a\n wireless interface specification for Bluetooth-based communication between\n devices. An example is the Hands-Free profile. For more discussion of\n profiles, see [Bluetooth profiles](/develop/connectivity/bluetooth/profiles).\n\n[`BluetoothHeadset`](/reference/android/bluetooth/BluetoothHeadset)\n: Provides support for Bluetooth headsets to be used with mobile phones. This\n includes both the Bluetooth Headset profile and the Hands-Free (v1.5) profile.\n\n[`BluetoothA2dp`](/reference/android/bluetooth/BluetoothA2dp)\n: Defines how high-quality audio can be streamed from one device to another over\n a Bluetooth connection using the Advanced Audio Distribution Profile (A2DP).\n\n[`BluetoothHealth`](/reference/android/bluetooth/BluetoothHealth)\n: Represents a Health Device Profile proxy that controls the Bluetooth service.\n\n[`BluetoothHealthCallback`](/reference/android/bluetooth/BluetoothHealthCallback)\n: An abstract class that you use to implement `BluetoothHealth` callbacks. You\n must extend this class and implement the callback methods to receive updates\n about changes in the app's registration state and Bluetooth channel\n state.\n\n[`BluetoothHealthAppConfiguration`](/reference/android/bluetooth/BluetoothHealthAppConfiguration)\n: Represents an app configuration that the Bluetooth Health third-party\n app registers to communicate with a remote Bluetooth health device.\n\n[`BluetoothProfile.ServiceListener`](/reference/android/bluetooth/BluetoothProfile.ServiceListener)\n: An interface that notifies `BluetoothProfile` interprocess communication (IPC)\n clients when they have been connected to or disconnected from the internal\n service that runs a particular profile."]]