使用 Cronet 執行網路作業
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Cronet 是 Chromium 網路堆疊,可做為 Android 應用程式使用的程式庫。Cronet 運用多項技術來縮短延遲時間,並提高應用程式運作所需的網路要求的處理量。
Cronet 程式庫每天處理數百萬人使用的應用程式要求,例如 YouTube、Google 應用程式、Google 相簿,以及 Google 地圖 - 導航和大眾運輸。
功能
- 通訊協定支援
- Cronet 原生支援 HTTP、HTTP/2 和 透過 QUIC 通訊協定的 HTTP/3。
- 要求排定優先順序
- 程式庫可讓你設定要求的優先順序標記。伺服器可以使用優先順序標記來決定處理要求的順序。
- 資源快取
- Cronet 可以使用記憶體或磁碟快取來儲存網路要求中擷取的資源。後續要求會自動從快取提供。
- 非同步請求
- 根據預設,使用 Cronet 程式庫發出的網路要求為非同步。等待要求恢復時,工作站執行緒不會遭到封鎖。
- 資料壓縮
- Cronet 支援使用 Brotli 壓縮資料格式的資料壓縮。
如要瞭解如何在 Android 版應用程式中使用 Cronet 程式庫,請參閱「傳送簡易要求」。您也可以瀏覽 GitHub 上的 Cronet 範例。
您可以使用 Chromium Issue Tracker 回報 Cronet 程式庫的意見回饋。查看 Issue Tracker 中的錯誤清單,確認您的問題尚未回報。如果您尚未回報問題,請在摘要行中以「Cronet」這個字回報錯誤。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[],[],null,["# Perform network operations using Cronet\n\nCronet is the Chromium network stack made available to Android apps as a\nlibrary. Cronet takes advantage of multiple technologies that reduce the latency\nand increase the throughput of the network requests that your app needs to work.\n\nThe Cronet Library handles the requests of apps used by millions of people on a\ndaily basis, such as\n[YouTube](https://play.google.com/store/apps/details?id=com.google.android.youtube),\n[Google App](https://play.google.com/store/apps/details?id=com.google.android.googlequicksearchbox),\n[Google Photos](https://play.google.com/store/apps/details?id=com.google.android.apps.photos),\nand [Maps - Navigation \\& Transit](https://play.google.com/store/apps/details?id=com.google.android.apps.maps).\n\nFeatures\n--------\n\n**Protocol support**\n: Cronet natively supports the\n [HTTP](https://tools.ietf.org/html/rfc2616),\n [HTTP/2](https://tools.ietf.org/html/rfc7540), and\n [HTTP/3 over QUIC](https://www.chromium.org/quic) protocols.\n\n**Request prioritization**\n: The library allows you to set a priority tag for the requests. The server can\n use the priority tag to determine the order in which to handle the requests.\n\n**Resource caching**\n: Cronet can use an in-memory or disk cache to store resources retrieved in\n network requests. Subsequent requests are served from the cache automatically.\n\n**Asynchronous requests**\n: Network requests issued using the Cronet Library are asynchronous by default.\n Your worker threads aren't blocked while waiting for the request to come back.\n\n**Data compression**\n: Cronet supports data compression using the\n [Brotli Compressed Data Format](https://tools.ietf.org/html/rfc7932).\n\nTo learn how to use the Cronet Library in your app for Android, see [Send a\nsimple request](/develop/connectivity/cronet/start). You can also\nbrowse the\n[Cronet Sample](https://github.com/GoogleChromeLabs/cronet-sample)\non GitHub.\n\nYou can send feedback about the Cronet Library using the [Chromium Issue\nTracker](https://crbug.com). Check the list of bugs in the issue tracker to make\nsure that your issue hasn't already been reported. If your issue hasn't been\nreported, file a bug with the word *Cronet* in the summary line."]]