連線指南
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
應用程式可以使用各種通訊技術 (包括 Wi-Fi、藍牙和 USB) 與外界連線。下列指南將說明如何新增這些技術的支援功能,以及如何針對連線功能最佳化應用程式。
支援的技術
Android 支援下列通訊協定和架構,可將裝置連線至外部世界。
指南 |
網路:總覽 |
總覽指南,涵蓋執行各種網路作業,包括連線、管理、剖析 XML 和監控等。 |
網路:5G |
善用 5G 網路。 |
網路:VPN |
為 Android 裝置開發及測試專屬的虛擬私人網路 (VPN) 用戶端。 |
網路:掃描 Wi-Fi |
取得裝置可見的 Wi-Fi 存取點清單。 |
網路:Wi-Fi Direct (P2P) |
不需透過中介存取點,即可讓支援的裝置直接連線。 |
網路:Wi-Fi Aware |
讓搭載 Android 8.0 (API 級別 26) 以上版本的裝置能夠彼此探索並直接連線,不必透過任何其他類型的連線方式。也稱為鄰近感知網路 (NAN)。 |
網路:Wi-Fi 封包往返時間 (RTT) |
測量距離附近支援 RTT 的 Wi-Fi 存取點和對等 Wi-Fi Aware 裝置。 |
網路:Wi-Fi 僅限本機的無線基地台 |
讓連線至 Wi-Fi 無線基地台的裝置上的應用程式彼此通訊。 |
藍牙:總覽 |
Android 藍牙支援總覽,包括基本資訊和重要類別與介面。 |
藍牙:藍牙經典 |
在應用程式中設定藍牙連線基準。 |
藍牙:藍牙低功耗 (BLE) |
在附近裝置之間傳輸少量資料,並與接近感應器互動。 |
藍牙:BLE 音訊 |
不必耗費大量電力,就可以讓使用者接收高傳真音訊,同時也能在不同用途間流暢切換。 |
近距離無線通訊 (NFC) |
NFC 是一組短程無線技術,通常需要在 4 公分以內的距離才能啟動連線。 |
測距 |
處理跨多種技術的測距工作階段。 |
電信 |
管理音訊和視訊通話,包括 eSIM 和 SIM 卡。 |
超寬頻 (UWB) 通訊 |
精確測量裝置之間的距離。 |
USB |
使用 USB 配件和 USB 主機模式,支援各種 USB 周邊裝置和 Android USB 配件。 |
最佳化
您可以參考下列指南,為應用程式進行連線最佳化調整。
指南 |
降低網路耗電量 |
瞭解如何延長電池續航力、提升使用者體驗,以及維持系統健康。 |
降低延遲時間並提高網路傳輸量 |
瞭解如何使用 Cronet (源自 Chromium 網路堆疊的程式庫),縮短網路要求的延遲時間並提高總處理量。 |
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間: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. |"]]