android - 如何获取 OkHttp 4.x 的 UserAgent?
问题描述
在 OkHttp 3.x 中,我们可以使用
import okhttp3.internal.Version
println(Version.userAgent())
但是,这在 OkHttp 4.x 中不再起作用。
在https://github.com/square/okhttp/issues/5969中提出了一个问题,并在https://github.com/square/okhttp/pull/5981中修复了,但我无法让它工作.
在更改日志中,声明从 4.7.0 版本开始。
New: Constant string okhttp3.VERSION. This is a string like “4.5.0-RC1”, “4.5.0”, or “4.6.0-SNAPSHOT” indicating the version of OkHttp in the current runtime. Use this to include the OkHttp version in custom User-Agent headers.
但我就是无法导入okhttp3.VERSION
解决方案
清除缓存并重新同步后,我现在可以拥有版本了
import okhttp3.OkHttp.VERSION
println(VERSION)
推荐阅读
- python - 刽子手隐藏python后如何显示字母
- https - 使用多个 HTTPS 证书运行 gunicorn?
- python - 使用 python 3.7(64 位)在 Windows 10 上下载 pybluez 时出错
- java - 在 main 中使用时找不到符号
- mysql - 我有一个 sql 转储我试图导入,但我得到一个语法错误
- ssh - 鱼壳新功能:“ssh:找不到命令”
- excel - VBA RunAll Macros 正在插入重复的列
- python-3.x - Python Adding Pictures and headers to QPrintWidget
- sql - In SQL how do I find the first record per-user if it's within a time slice, without scanning the entire DB
- reactjs - How to reset form after successful sent Redux Form