连接指南
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
您的应用可以使用各种不同的通信技术(包括 Wi-Fi、蓝牙和 USB)与外界建立连接。下列指南介绍了如何添加对这些技术的支持,以及如何优化应用以实现连接。
支持的技术
Android 支持以下协议和框架,用于将设备连接到外部世界。
指南 |
网络:概览 |
指南概览:介绍如何执行各种网络操作,包括连接、管理、解析 XML、监控等。 |
网络:5G |
利用 5G 网络。 |
网络:VPN |
为 Android 设备开发和测试自己的虚拟专用网 (VPN) 客户端。 |
网络:WLAN 扫描 |
获取设备上可见的 Wi-Fi 接入点列表。 |
网络:Wi-Fi 直连(点对点) |
支持的设备可直接彼此连接,而无需中间接入点。 |
网络:Wi-Fi 感知 |
使搭载 Android 8.0(API 级别 26)及更高版本的设备能够发现彼此并直接进行连接,它们之间无需任何其他类型的连接。也称为“邻近感知网络”(NAN)。 |
网络:Wi-Fi 往返时间 (RTT) |
测量距附近支持 RTT 的 Wi-Fi 接入点和 Wi-Fi 感知对等设备的距离。 |
网络:仅限本地使用的 WLAN 热点 |
允许连接到 Wi-Fi 热点的设备上的应用相互通信。 |
蓝牙:概览 |
Android 蓝牙支持概览,包括基础知识以及关键类和接口。 |
蓝牙:传统蓝牙 |
在应用中设置基准蓝牙连接。 |
蓝牙:蓝牙低功耗 (BLE) |
在附近的设备之间传输少量数据,并与接近传感器互动。 |
蓝牙:BLE 音频 |
接收高保真度音频,而不必牺牲电池续航时间,并让用户能够在不同使用情形之间无缝切换。 |
近距离无线通信 (NFC) |
NFC 是一组近距离无线技术,通常只有在距离不超过 4 厘米时才能启动连接。 |
排名 |
处理跨多种技术的测距会话。 |
电信 |
管理音频和视频通话,包括 eSIM 卡和 SIM 卡。 |
超宽带 (UWB) 通信 |
测量设备之间的精确测距。 |
USB |
使用 USB 配件和 USB 主机模式支持各种 USB 外围设备和 Android USB 配件。 |
优化
以下指南可帮助您优化应用的连接性。
指南 |
减少网络耗电量 |
了解延长电池续航时间、提升用户体验和系统运行状况的策略。 |
缩短延迟时间并提高网络吞吐量 |
了解如何使用 Cronet(一种派生自 Chromium 网络堆栈的库)来缩短网络请求的延迟时间并提高其吞吐量。 |
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Connectivity guides\n\nYour app can connect with the outside world using a variety of different\ncommunication technologies, including Wi-Fi, Bluetooth, and USB. The guides\nlisted below cover adding support for these technologies and for optimizing\nyour app for connectivity.\n\nSupported technologies\n----------------------\n\nAndroid supports the following protocols and frameworks for connecting your\ndevice to the outside world.\n\n| Guides ||\n|-----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Networks: [**Overview**](/develop/connectivity/network-ops) | Overview of guides that cover performing various network operations, including connections, management, parsing XML, monitoring, and more. |\n| Networks: [**5G**](/develop/connectivity/5g/enhance-with-5g) | Take advantage of 5G networking. |\n| Networks: [**VPN**](/develop/connectivity/vpn) | Develop and test your own virtual private network (VPN) client for an Android-powered device. |\n| Networks: [**Wi-Fi scanning**](/develop/connectivity/wifi-scan) | Get a list of Wi-Fi access points visible from a device. |\n| Networks: [**Wi-Fi Direct (P2P)**](/develop/connectivity/wifip2p) | Connect supported devices directly to each other without an intermediate access point. |\n| Networks: [**Wi-Fi Aware**](/develop/connectivity/wifi-aware) | Enable devices running Android 8.0 (API level 26) and higher to discover and connect directly to each other without any other type of connectivity between them. Also known as Neighbor Awareness Networking (NAN). |\n| Networks: [**Wi-Fi Round-Trip Time (RTT)**](/develop/connectivity/wifi-rtt) | Measure the distance to nearby RTT-capable Wi-Fi access points and peer Wi-Fi Aware devices. |\n| Networks: [**Wi-Fi local-only hotspot**](/develop/connectivity/localonlyhotspot) | Enable apps on devices connected to a Wi-Fi hotspot to communicate with each other. |\n| Bluetooth: [**Overview**](/develop/connectivity/bluetooth) | Overview of Android Bluetooth support, including basics and key classes and interfaces. |\n| Bluetooth: [**Bluetooth Classic**](/develop/connectivity/bluetooth/setup) | Set up baseline Bluetooth connectivity on your app. |\n| Bluetooth: [**Bluetooth Low Energy (BLE)**](/develop/connectivity/bluetooth/ble/ble-overview) | Transfer small amounts of data between nearby devices and interacting with proximity sensors. |\n| Bluetooth: [**BLE Audio**](/develop/connectivity/bluetooth/ble-audio/overview) | Receive high fidelity audio without sacrificing battery life, and let users seamlessly switch between different use cases. |\n| [**Near Field Communication (NFC)**](/develop/connectivity/nfc) | NFC is a set of short-range wireless technologies, typically requiring a distance of 4 cm or less to initiate a connection. |\n| [**Ranging**](/develop/connectivity/ranging) | Handle ranging sessions across multiple technologies. |\n| [**Telecom**](/develop/connectivity/telecom) | Manage audio and video calls, including eSIMs and SIM cards. |\n| [**Ultra Wideband (UWB) communication**](/develop/connectivity/uwb) | Measure precise ranging between devices. |\n| [**USB**](/develop/connectivity/usb) | Use USB accessory and USB host modes to support a variety of USB peripherals and Android USB accessories. |\n\nOptimizations\n-------------\n\nThe following guides can help you optimize your app for connectivity.\n\n| Guides ||\n|--------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|\n| [Reduce network battery drainage](/develop/connectivity/preserving-battery) | Learn about strategies for preserving battery, user experience, and system health. |\n| [Reduce latency and increase network throughput](/develop/connectivity/cronet) | Learn how to use Cronet, a library derived from the Chromium network stack, to reduce latency and increase throughput of network requests. |"]]