메일링 리스트에 가입하여 Nearby에 관한 소식 및 공지사항을 확인하세요.
개요
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Nearby Connections는 앱이 네트워크 연결과 관계없이 실시간으로 주변 기기를 쉽게 검색하고, 연결하고, 데이터를 교환할 수 있는 P2P 네트워킹 API입니다.
사용 사례 예시:
- 공동작업용 화이트보드: 공유 가상 화이트보드에서 근처에 있는 참석자와 함께 아이디어를 적어 보세요.
- 로컬 멀티플레이어 게임: 멀티플레이어 게임을 설정하고 근처에 있는 다른 사용자를 초대하여 참여시킵니다.
- 멀티스크린 게임: 휴대전화나 태블릿을 게임 컨트롤러로 사용하여 Android TV와 같은 근처의 대형 Android 기기에 표시된 게임을 플레이합니다.
- 오프라인 파일 전송: 네트워크 연결 없이도 사진, 동영상 또는 기타 유형의 데이터를 빠르게 공유할 수 있습니다.
소개
Nearby Connections를 사용하면 완전히 오프라인 P2P 방식으로 근처 기기 간 광고, 검색, 연결이 가능합니다. 기기 간 연결은 대역폭이 높고 지연 시간이 짧으며 완전히 암호화되어 빠르고 안전한 데이터 전송이 가능합니다.
이 API의 기본 목표는 간단하고 안정적이며 성능이 뛰어난 플랫폼을 제공하는 것입니다. 내부적으로 API는 블루투스, BLE, Wi-Fi 기술을 조합하여 각 기술의 장점을 활용하고 각 기술의 약점을 우회합니다. 이를 통해 다양한 플랫폼과 OS 버전에서 블루투스와 Wi-Fi의 변동성을 효과적으로 추상화하여 개발자가 사용자에게 중요한 기능에 집중할 수 있습니다.
API 개요
API 사용은 연결 전과 연결 후의 두 단계로 나뉩니다.
연결 전 단계에서 광고주는 자신을 광고하고 검색자는 근처 광고주를 검색하여 연결 요청을 보냅니다. 탐색기에서 광고주로의 연결 요청은 양쪽에서 독립적으로 연결 요청을 수락하거나 거부하는 대칭 인증 흐름을 시작합니다.
연결 요청이 양쪽에서 수락되면 연결이 설정된 것으로 간주되고 기기가 연결 후 단계로 전환됩니다. 이 단계에서는 양쪽에서 데이터를 교환할 수 있습니다.
광고 및 탐색
광고주는 다른 디스커버에 표시되며, 새로운 광고주가 발견되거나 사라지면 디스커버러에게 알림이 전송됩니다.
연결 설정
검색자가 근처 광고주에 연결하려는 경우 검색자는 연결을 요청할 수 있습니다.
연결 시작 프로세스가 양측에 모두 알림으로 전송되며 양측 모두 연결을 수락하거나 거부할 수 있습니다.
양쪽에서 모두 응답하면 각 사용자에게 결과가 통지됩니다. 양쪽에서 연결을 수락하면 연결이 설정된 것으로 간주되며 데이터 전송이 시작될 수 있습니다.
데이터 교환
연결이 설정된 후에는 추가 API 사용이 대칭적이므로 더 이상 광고주와 검색자 간의 구분이 없습니다.
이제 양쪽에서 데이터를 교환할 수 있습니다. 지원되는 페이로드에는 3가지 유형이 있습니다.
- 바이트: 32k로 제한된 바이트 배열입니다. 메타데이터나 제어 메시지와 같은 항목을 전송하는 데 적합합니다.
- 파일: 모든 크기의 파일입니다. 프로세스 경계를 넘어 최소한의 복사로 앱에서 네트워크 인터페이스로 전송됩니다.
- 스트림: 녹음된 오디오/동영상과 같이 미리 최종 크기를 알 수 없으며 즉석에서 생성되는 데이터 스트림입니다.
수신자에게 새로운 수신 데이터와 진행 상황 업데이트, 취소 또는 실패가 알림으로 전송됩니다.
설정된 연결은 전이중이므로 광고주와 탐색기가 동시에 데이터를 보내고 받을 수 있습니다.
데이터 수집
Google Play 서비스 Nearby SDK를 사용하면 환경을 개선하기 위해 사용 분석이 수집됩니다.
- 성능 측정항목: Nearby SDK를 사용하여 기기를 검색하고 연결할 때 검색 및 연결 지연 시간, 안정성, 처리량이 수집됩니다.
- 기기 정보: 지역별 및 기기별 슬라이스를 식별하기 위해 기기 모델, 국가, 빌드 버전, 애플리케이션 패키지 이름이 수집되어 성능 측정항목과 연결됩니다.
최종 사용자는 설정 > Google > 사용 및 진단으로 이동하여 이 수집을 허용하거나 거부할 수 있습니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-13(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-08-13(UTC)"],[[["\u003cp\u003eNearby Connections is a peer-to-peer networking API enabling apps to discover, connect, and exchange data with nearby devices in real-time, even without internet access.\u003c/p\u003e\n"],["\u003cp\u003eIt leverages Bluetooth, BLE, and Wi-Fi for high-bandwidth, low-latency, and encrypted communication, abstracting away the complexities of these technologies.\u003c/p\u003e\n"],["\u003cp\u003eThe API facilitates advertising, discovery, and connection establishment between devices, followed by data exchange using bytes, files, or streams.\u003c/p\u003e\n"],["\u003cp\u003eUsage analytics, including performance metrics and device information, are collected to enhance the API's performance but can be controlled by users in their device settings.\u003c/p\u003e\n"]]],[],null,["# Overview\n\nNearby Connections is a peer-to-peer networking API that allows apps to easily\ndiscover, connect to, and exchange data with nearby devices in real-time,\nregardless of network connectivity.\n\nSome example use cases:\n\n- **Collaborative whiteboard:** Jot ideas down with nearby participants on a shared virtual whiteboard.\n- **Local multiplayer gaming:** Set up a multiplayer game and invite other users nearby to join.\n- **Multi-screen gaming:** Use a phone or tablet as a game controller to play games displayed on a nearby large-screen Android device, such as Android TV.\n- **Offline file transfers:** Share photos, videos, or any other type of data quickly and without requiring a network connection.\n\nIntroduction\n------------\n\nNearby Connections enables advertising, discovery, and connections between\nnearby devices in a fully-offline peer-to-peer manner. Connections between\ndevices are high-bandwidth, low-latency, and fully encrypted to enable fast,\nsecure data transfers.\n\nA primary goal of this API is to provide a platform that is simple, reliable,\nand performant. Under the hood, the API uses a combination of Bluetooth, BLE,\nand Wi-Fi technologies, leveraging the strengths of each while circumventing\ntheir respective weaknesses. This effectively abstracts the vagaries of\nBluetooth and Wi-Fi across a range of platforms and OS versions, allowing\ndevelopers to focus on the features that matter to their users.\n\nAPI overview\n------------\n\nUsage of the API falls into two phases: pre-connection, and post-connection.\n\nIn the pre-connection phase, Advertisers advertise themselves, while Discoverers\ndiscover nearby Advertisers and send connection requests. A connection request\nfrom a Discoverer to an Advertiser initiates a symmetric authentication flow\nthat results in both sides independently accepting (or rejecting) the connection\nrequest.\n\nAfter a connection request is accepted by both sides, the connection is\nconsidered to be established and the devices enter the post-connection phase,\nduring which both sides can exchange data.\n\n### Advertising and discovery\n\nAdvertisers will become visible to other discovers and discoverers will be\nnotified when a new advertiser is found or has been lost.\n\n### Establishing connections\n\nWhen a discoverer wishes to connect to a nearby advertiser, the discoverer can\nrequest a connection.\n\nBoth sides will be notified of the connection initiation process and both will\nhave the opportunity to accept or reject the connection.\n\nOnce both sides have responded, each will be notified of the result. If both\nsides accepted the connection, the connection is considered established, and\ndata transference can then begin.\n\n### Exchanging data\n\nAfter a connection is established, further API usage is symmetrical, so there's\nno longer a distinction between Advertiser and Discoverer.\n\nBoth sides can now exchange data. There are 3 types of supported Payloads:\n\n- **Bytes:** Byte arrays limited to 32k; these are good for sending things such as metadata or control messages.\n- **File:** Files of any size; these are transferred from the app to the network interface with minimal copying across process boundaries.\n- **Stream:** A stream of data that is generated on the fly, as in the case of recorded audio/video, with no final size known beforehand.\n\nReceivers will be notified of new incoming data and any progress updates,\ncancellations or failures.\n\nThe connections established are full-duplex, which means that advertisers and\ndiscoverers can simultaneously send and receive data.\n\n### Data Collection\n\nWhen using the Google Play services Nearby SDK, usage analytics are collected to\nimprove the experience.\n\n- **Performance metrics:** Discovery and connection latency, reliability and throughput are collected when scanning for and connecting to devices using the Nearby SDK.\n- **Device information:** Device model, country, build version and the application package name are collected and associated with the performance metrics to identify regional and device-specific slices.\n\nEnd users can allow or deny this collection by navigating to Settings \\\u003e Google \\\u003e\nUsage \\& diagnostics."]]