使用 Cronet 执行网络操作
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Cronet 是以库的形式提供给 Android 应用使用的 Chromium 网络堆栈。Cronet 利用多种技术来减少延迟并提高应用正常运行所需的网络请求吞吐量。
Cronet 库每天处理数百万用户所使用的应用(例如 YouTube、Google 应用、Google 相册以及 Google 地图 - 导航和公交)的请求。
功能
- 协议支持
- Cronet 原生支持 HTTP、HTTP/2 和 HTTP/3 over QUIC 协议。
- 请求优先级
- 该库支持您为请求设置优先级标签。服务器可以使用优先级标记来确定处理请求的顺序。
- 资源缓存
- Cronet 可以使用内存缓存或磁盘缓存来存储网络请求中检索到的资源。后续请求会自动从缓存中传送。
- 异步请求
- 默认情况下,使用 Cronet 库发出的网络请求是异步的。在等待请求返回时,您的工作器线程不会被阻塞。
- 数据压缩
- Cronet 支持使用 Brotli 压缩数据格式进行数据压缩。
如需了解如何在 Android 应用中使用 Cronet 库,请参阅发送简单请求。您还可以在 GitHub 上浏览 Cronet 示例。
您可以使用 Chromium 问题跟踪器发送有关 Cronet 库的反馈。查看问题跟踪器中的 bug 列表,确保其他人尚未报告过您遇到的问题。如果尚未报告您的问题,请提交 bug,并在摘要行中显示 Cronet 一词。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[[["易于理解","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"]],["最后更新时间 (UTC):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."]]