日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

okhttp 对应java版本_java – Android |在运行时获取OkHTTP库版本

發布時間:2025/4/16 Android 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 okhttp 对应java版本_java – Android |在运行时获取OkHTTP库版本 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

從4.xx谷歌正在使用okhttp部分的平方

/**

* This implementation uses HttpEngine to send requests and receive responses. This class may use

* multiple HttpEngines to follow redirects, authentication retries, etc. to retrieve the final

* response body.

*

*

What does 'connected' mean?

This class inherits a {@code connected} field from the

* superclass. That field is not used to indicate whether this URLConnection is

* currently connected. Instead, it indicates whether a connection has ever been attempted. Once a

* connection has been attempted, certain properties (request header fields, request method, etc.)

* are immutable.

*/

public class HttpURLConnectionImpl extends HttpURLConnection {

private String defaultUserAgent() {

String agent = System.getProperty("http.agent");

return agent != null ? Util.toHumanReadableAscii(agent) : Version.userAgent();

}

一切都取決于設備 – 你使用的os版本,因為api正在發展,你可以使用反射,但你需要知道特定的api是什么字段

你可以在一開始就試試

System.getProperty("http.agent");

編輯:

通過反思

HttpURLConnection connection = (HttpURLConnection) new URL("http://google.com")

.openConnection();

Method method = connection.getClass().getDeclaredMethod("defaultUserAgent");

method.setAccessible(true);

String okEngineVersion = (String) method.invoke(connection, new Object[]{});

與…一樣

String okEngineVersion = System.getProperty("http.agent");

如果你想打擾:

>每個班級都以同樣的方式對待 – > as equals(沒有版本控制 – 你只能查看魔術次要主編號 – 來自類的java編譯器版本)

> /system/framework/okhttp.jar的清單不包含版本屬性

如果你想要okhttp.internal.Version類,那么:

File file = new File("/system/framework/okhttp.jar");

// using javaxt-core lib

Jar jar = new Jar(file);

jar.getVersion();

// load dex

DexFile dexfile = DexFile.loadDex(file.getAbsolutePath(),

File.createTempFile("opt", "dex", _context.getCacheDir()).getPath(), 0);

Enumeration dexEntries = dexfile.entries();

ClassLoader systemClassLoader = DexClassLoader.getSystemClassLoader();

while (dexEntries.hasMoreElements()) {

String className = dexEntries.nextElement();

Class> aClass = systemClassLoader.loadClass(className);

}

conclusion: If you want to avoid crash of app from library changes delivery own version of library and load classes on the fly or compile with apk

總結

以上是生活随笔為你收集整理的okhttp 对应java版本_java – Android |在运行时获取OkHTTP库版本的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。