Android okhttp的啟動(dòng)流程及源碼解析
前言
這篇文章主要講解了okhttp的主要工作流程以及源碼的解析。
什么是OKhttp
簡(jiǎn)單來(lái)說(shuō) OkHttp 就是一個(gè)客戶端用來(lái)發(fā)送 HTTP 消息并對(duì)服務(wù)器的響應(yīng)做出處理的應(yīng)用層框架。 那么它有什么優(yōu)點(diǎn)呢?
- 易使用、易擴(kuò)展。
- 支持 HTTP/2 協(xié)議,允許對(duì)同一主機(jī)的所有請(qǐng)求共用同一個(gè) socket 連接。
- 如果 HTTP/2 不可用, 使用連接池復(fù)用減少請(qǐng)求延遲。
- 支持 GZIP,減小了下載大小。
- 支持緩存處理,可以避免重復(fù)請(qǐng)求。
- 如果你的服務(wù)有多個(gè) IP 地址,當(dāng)?shù)谝淮芜B接失敗,OkHttp 會(huì)嘗試備用地址。
- OkHttp 還處理了代理服務(wù)器問(wèn)題和SSL握手失敗問(wèn)題。
OkHttp是如何做網(wǎng)絡(luò)請(qǐng)求的
1.它是如何使用的?
1.1 通過(guò)構(gòu)造者模式添加 url,method,header,body 等完成一個(gè)請(qǐng)求的信息 Request 對(duì)象
val request = Request.Builder()
.url("")
.addHeader("","")
.get()
.build()
1.2 同樣通過(guò)構(gòu)造者模式創(chuàng)建一個(gè) OkHttpClicent 實(shí)例,可以按需配置
val okHttpClient = OkHttpClient.Builder()
.connectTimeout(15, TimeUnit.SECONDS)
.readTimeout(15, TimeUnit.SECONDS)
.addInterceptor()
.build()
1.3 創(chuàng)建 Call 并且發(fā)起網(wǎng)絡(luò)請(qǐng)求
val newCall = okHttpClient.newCall(request)
//異步請(qǐng)求數(shù)據(jù)
newCall.enqueue(object :Callback{
override fun onFailure(call: Call, e: IOException) {}
override fun onResponse(call: Call, response: Response) {}
})
//同步請(qǐng)求數(shù)據(jù)
val response = newCall.execute()
整個(gè)使用流程很簡(jiǎn)單,主要的地方在于如何通過(guò) Call 對(duì)象發(fā)起同/異步請(qǐng)求,后續(xù)的源碼追蹤以方法開(kāi)始。
2.如何通過(guò) Call 發(fā)起請(qǐng)求?
2.1 Call 是什么
/** Prepares the [request] to be executed at some point in the future. */ override fun newCall(request: Request): Call = RealCall(this, request, forWebSocket = false)
2.2 發(fā)起請(qǐng)求-異步請(qǐng)求
//RealCall#enqueue(responseCallback: Callback)
override fun enqueue(responseCallback: Callback) {
synchronized(this) {
//檢查這個(gè)call是否執(zhí)行過(guò),每個(gè) call 只能被執(zhí)行一次
check(!executed) { "Already Executed" }
executed = true
}
//此方法調(diào)用了EventListener#callStart(call: Call),
主要是用來(lái)監(jiān)視應(yīng)用程序的HTTP調(diào)用的數(shù)量,大小和各個(gè)階段的耗時(shí)
callStart()
//創(chuàng)建AsyncCall,實(shí)際是個(gè)Runnable
client.dispatcher.enqueue(AsyncCall(responseCallback))
}
enqueue 最后一個(gè)方法分為兩步
- 第一步將響應(yīng)的回調(diào)放入 AsyncCall 對(duì)象中 ,AsyncCall 對(duì)象是 RealCall 的一個(gè)內(nèi)部類實(shí)現(xiàn)了 Runnable 接口。
- 第二步通過(guò) Dispatcher 類的 enqueue() 將 AsyncCall 對(duì)象傳入
//Dispatcher#enqueue(call: AsyncCall)
/** Ready async calls in the order they'll be run. */
private val readyAsyncCalls = ArrayDeque<AsyncCall>()
internal fun enqueue(call: AsyncCall) {
synchronized(this) {
//將call添加到即將運(yùn)行的異步隊(duì)列
readyAsyncCalls.add(call)
...
promoteAndExecute()
}
//Dispatcher#promoteAndExecute()
//將[readyAsyncCalls]過(guò)渡到[runningAsyncCalls]
private fun promoteAndExecute(): Boolean {
...
for (i in 0 until executableCalls.size) {
val asyncCall = executableCalls[i]
//這里就是通過(guò) ExecutorService 執(zhí)行 run()
asyncCall.executeOn(executorService)
}
return isRunning
}
//RealCall.kt中的內(nèi)部類
internal inner class AsyncCall(
private val responseCallback: Callback
) : Runnable {
fun executeOn(executorService: ExecutorService) {
...
//執(zhí)行Runnable
executorService.execute(this)
...
}
override fun run() {
threadName("OkHttp ${redactedUrl()}") {
...
try {
//兜兜轉(zhuǎn)轉(zhuǎn) 終于調(diào)用這個(gè)關(guān)鍵方法了
val response = getResponseWithInterceptorChain()
signalledCallback = true
//通過(guò)之前傳入的接口回調(diào)數(shù)據(jù)
responseCallback.onResponse(this@RealCall, response)
} catch (e: IOException) {
if (signalledCallback) {
Platform.get().log("Callback failure for ${toLoggableString()}", Platform.INFO, e)
} else {
responseCallback.onFailure(this@RealCall, e)
}
} catch (t: Throwable) {
cancel()
if (!signalledCallback) {
val canceledException = IOException("canceled due to $t")
canceledException.addSuppressed(t)
responseCallback.onFailure(this@RealCall, canceledException)
}
throw t
} finally {
//移除隊(duì)列
client.dispatcher.finished(this)
}
}
}
}
2.3 同步請(qǐng)求 RealCall#execute()
override fun execute(): Response {
//同樣判斷是否執(zhí)行過(guò)
synchronized(this) {
check(!executed) { "Already Executed" }
executed = true
}
timeout.enter()
//同樣監(jiān)聽(tīng)
callStart()
try {
//同樣執(zhí)行
client.dispatcher.executed(this)
return getResponseWithInterceptorChain()
} finally {
//同樣移除
client.dispatcher.finished(this)
}
}
3.如何通過(guò)攔截器處理請(qǐng)求和響應(yīng)?
無(wú)論同異步請(qǐng)求都會(huì)調(diào)用到 getResponseWithInterceptorChain() ,這個(gè)方法主要使用責(zé)任鏈模式將整個(gè)請(qǐng)求分為幾個(gè)攔截器調(diào)用 ,簡(jiǎn)化了各自的責(zé)任和邏輯,可以擴(kuò)展其它攔截器,看懂了攔截器 OkHttp 就了解的差不多了。
@Throws(IOException::class)
internal fun getResponseWithInterceptorChain(): Response {
// 構(gòu)建完整的攔截器
val interceptors = mutableListOf<Interceptor>()
interceptors += client.interceptors //用戶自己攔截器,數(shù)據(jù)最開(kāi)始和最后
interceptors += RetryAndFollowUpInterceptor(client) //失敗后的重試和重定向
interceptors += BridgeInterceptor(client.cookieJar) //橋接用戶的信息和服務(wù)器的信息
interceptors += CacheInterceptor(client.cache) //處理緩存相關(guān)
interceptors += ConnectInterceptor //負(fù)責(zé)與服務(wù)器連接
if (!forWebSocket) {
interceptors += client.networkInterceptors //配置 OkHttpClient 時(shí)設(shè)置,數(shù)據(jù)未經(jīng)處理
}
interceptors += CallServerInterceptor(forWebSocket) //負(fù)責(zé)向服務(wù)器發(fā)送請(qǐng)求數(shù)據(jù)、從服務(wù)器讀取響應(yīng)數(shù)據(jù)
//創(chuàng)建攔截鏈
val chain = RealInterceptorChain(
call = this,
interceptors = interceptors,
index = 0,
exchange = null,
request = originalRequest,
connectTimeoutMillis = client.connectTimeoutMillis,
readTimeoutMillis = client.readTimeoutMillis,
writeTimeoutMillis = client.writeTimeoutMillis
)
var calledNoMoreExchanges = false
try {
//攔截鏈的執(zhí)行
val response = chain.proceed(originalRequest)
...
} catch (e: IOException) {
...
} finally {
...
}
}
//1.RealInterceptorChain#proceed(request: Request)
@Throws(IOException::class)
override fun proceed(request: Request): Response {
...
// copy出新的攔截鏈,鏈中的攔截器集合index+1
val next = copy(index = index + 1, request = request)
val interceptor = interceptors[index]
//調(diào)用攔截器的intercept(chain: Chain): Response 返回處理后的數(shù)據(jù) 交由下一個(gè)攔截器處理
@Suppress("USELESS_ELVIS")
val response = interceptor.intercept(next) ?: throw NullPointerException(
"interceptor $interceptor returned null")
...
//返回最終的響應(yīng)體
return response
}
攔截器開(kāi)始操作 Request。
3.1 攔截器是怎么攔截的?
攔截器都繼承自 Interceptor 類并實(shí)現(xiàn)了 fun intercept(chain: Chain): Response 方法。
在 intercept 方法里傳入 chain 對(duì)象 調(diào)用它的 proceed() 然后 proceed() 方法里又 copy 下一個(gè)攔截器,然后雙調(diào)用了 intercept(chain: Chain) 接著叒 chain.proceed(request) 直到最后一個(gè)攔截器 return response 然后一層一層向上反饋數(shù)據(jù)。
3.2 RetryAndFollowUpInterceptor
這個(gè)攔截器是用來(lái)處理重定向的后續(xù)請(qǐng)求和失敗重試,也就是說(shuō)一般第一次發(fā)起請(qǐng)求不需要重定向會(huì)調(diào)用下一個(gè)攔截器。
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
val realChain = chain as RealInterceptorChain
var request = chain.request
val call = realChain.call
var followUpCount = 0
var priorResponse: Response? = null
var newExchangeFinder = true
var recoveredFailures = listOf<IOException>()
while (true) {
...//在調(diào)用下一個(gè)攔截器前的操作
var response: Response
try {
...
try {
//調(diào)用下一個(gè)攔截器
response = realChain.proceed(request)
newExchangeFinder = true
} catch (e: RouteException) {
...
continue
} catch (e: IOException) {
...
continue
}
...
//處理上一個(gè)攔截器返回的 response
val followUp = followUpRequest(response, exchange)
...
//中間有一些判斷是否需要重新請(qǐng)求 不需要?jiǎng)t返回 response
//處理之后重新請(qǐng)求 Request
request = followUp
priorResponse = response
} finally {
call.exitNetworkInterceptorExchange(closeActiveExchange)
}
}
}
@Throws(IOException::class)
private fun followUpRequest(userResponse: Response, exchange: Exchange?): Request? {
val route = exchange?.connection?.route()
val responseCode = userResponse.code
val method = userResponse.request.method
when (responseCode) {
//3xx 重定向
HTTP_PERM_REDIRECT, HTTP_TEMP_REDIRECT, HTTP_MULT_CHOICE, HTTP_MOVED_PERM, HTTP_MOVED_TEMP, HTTP_SEE_OTHER -> {
//這個(gè)方法重新 構(gòu)建了 Request 用于重新請(qǐng)求
return buildRedirectRequest(userResponse, method)
}
... 省略一部分code
else -> return null
}
}
在 followUpRequest(userResponse: Response, exchange: Exchange?): Request? 方法中判斷了 response 中的服務(wù)器響應(yīng)碼做出了不同的操作。
3.3 BridgeInterceptor
它負(fù)責(zé)對(duì)于 Http 的額外預(yù)處理,比如 Content-Length 的計(jì)算和添加、 gzip 的⽀持(Accept-Encoding: gzip)、 gzip 壓縮數(shù)據(jù)的解包等,這個(gè)類比較簡(jiǎn)單就不貼代碼了,想了解的話可以自行查看。
3.4 CacheInterceptor
這個(gè)類負(fù)責(zé) Cache 的處理,如果本地有了可⽤的 Cache,⼀個(gè)請(qǐng)求可以在沒(méi)有發(fā)⽣實(shí)質(zhì)⽹絡(luò)交互的情況下就返回緩存結(jié)果,實(shí)現(xiàn)如下。
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
//在Cache(DiskLruCache)類中 通過(guò)request.url匹配response
val cacheCandidate = cache?.get(chain.request())
//記錄當(dāng)前時(shí)間點(diǎn)
val now = System.currentTimeMillis()
//緩存策略 有兩種類型
//networkRequest 網(wǎng)絡(luò)請(qǐng)求
//cacheResponse 緩存的響應(yīng)
val strategy = CacheStrategy.Factory(now, chain.request(), cacheCandidate).compute()
val networkRequest = strategy.networkRequest
val cacheResponse = strategy.cacheResponse
//計(jì)算請(qǐng)求次數(shù)和緩存次數(shù)
cache?.trackResponse(strategy)
...
// 如果 禁止使用網(wǎng)絡(luò) 并且 緩存不足,返回504和空body的Response
if (networkRequest == null && cacheResponse == null) {
return Response.Builder()
.request(chain.request())
.protocol(Protocol.HTTP_1_1)
.code(HTTP_GATEWAY_TIMEOUT)
.message("Unsatisfiable Request (only-if-cached)")
.body(EMPTY_RESPONSE)
.sentRequestAtMillis(-1L)
.receivedResponseAtMillis(System.currentTimeMillis())
.build()
}
// 如果策略中不能使用網(wǎng)絡(luò),就把緩存中的response封裝返回
if (networkRequest == null) {
return cacheResponse!!.newBuilder()
.cacheResponse(stripBody(cacheResponse))
.build()
}
//調(diào)用攔截器process從網(wǎng)絡(luò)獲取數(shù)據(jù)
var networkResponse: Response? = null
try {
networkResponse = chain.proceed(networkRequest)
} finally {
// If we're crashing on I/O or otherwise, don't leak the cache body.
if (networkResponse == null && cacheCandidate != null) {
cacheCandidate.body?.closeQuietly()
}
}
//如果有緩存的Response
if (cacheResponse != null) {
//如果網(wǎng)絡(luò)請(qǐng)求返回code為304 即說(shuō)明資源未修改
if (networkResponse?.code == HTTP_NOT_MODIFIED) {
//直接封裝封裝緩存的Response返回即可
val response = cacheResponse.newBuilder()
.headers(combine(cacheResponse.headers, networkResponse.headers))
.sentRequestAtMillis(networkResponse.sentRequestAtMillis)
.receivedResponseAtMillis(networkResponse.receivedResponseAtMillis)
.cacheResponse(stripBody(cacheResponse))
.networkResponse(stripBody(networkResponse))
.build()
networkResponse.body!!.close()
// Update the cache after combining headers but before stripping the
// Content-Encoding header (as performed by initContentStream()).
cache!!.trackConditionalCacheHit()
cache.update(cacheResponse, response)
return response
} else {
cacheResponse.body?.closeQuietly()
}
}
val response = networkResponse!!.newBuilder()
.cacheResponse(stripBody(cacheResponse))
.networkResponse(stripBody(networkResponse))
.build()
if (cache != null) {
//判斷是否具有主體 并且 是否可以緩存供后續(xù)使用
if (response.promisesBody() && CacheStrategy.isCacheable(response, networkRequest)) {
// 加入緩存中
val cacheRequest = cache.put(response)
return cacheWritingResponse(cacheRequest, response)
}
//如果請(qǐng)求方法無(wú)效 就從緩存中remove掉
if (HttpMethod.invalidatesCache(networkRequest.method)) {
try {
cache.remove(networkRequest)
} catch (_: IOException) {
// The cache cannot be written.
}
}
}
return response
}
3.5 ConnectInterceptor
此類負(fù)責(zé)建⽴連接。 包含了⽹絡(luò)請(qǐng)求所需要的 TCP 連接(HTTP),或者 TCP 之前的 TLS 連接(HTTPS),并且會(huì)創(chuàng)建出對(duì)應(yīng)的 HttpCodec 對(duì)象(⽤于編碼解碼 HTTP 請(qǐng)求)。
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
val realChain = chain as RealInterceptorChain
val exchange = realChain.call.initExchange(chain)
val connectedChain = realChain.copy(exchange = exchange)
return connectedChain.proceed(realChain.request)
}
看似短短四行實(shí)際工作還是比較多的。
/** Finds a new or pooled connection to carry a forthcoming request and response. */
internal fun initExchange(chain: RealInterceptorChain): Exchange {
...
//codec是對(duì) HTTP 協(xié)議操作的抽象,有兩個(gè)實(shí)現(xiàn):Http1Codec和Http2Codec,對(duì)應(yīng) HTTP/1.1 和 HTTP/2。
val codec = exchangeFinder.find(client, chain)
val result = Exchange(this, eventListener, exchangeFinder, codec)
...
return result
}
#ExchangeFinder.find
fun find(client: OkHttpClient,chain: RealInterceptorChain):ExchangeCodec {
try {
//尋找一個(gè)可用的連接
val resultConnection = findHealthyConnection(
connectTimeout = chain.connectTimeoutMillis,
readTimeout = chain.readTimeoutMillis,
writeTimeout = chain.writeTimeoutMillis,
pingIntervalMillis = client.pingIntervalMillis,
connectionRetryEnabled = client.retryOnConnectionFailure,
doExtensiveHealthChecks = chain.request.method != "GET"
)
return resultConnection.newCodec(client, chain)
} catch (e: RouteException) {
trackFailure(e.lastConnectException)
throw e
} catch (e: IOException) {
trackFailure(e)
throw RouteException(e)
}
}
@Throws(IOException::class)
private fun findHealthyConnection(
connectTimeout: Int,
readTimeout: Int,
writeTimeout: Int,
pingIntervalMillis: Int,
connectionRetryEnabled: Boolean,
doExtensiveHealthChecks: Boolean
): RealConnection {
while (true) {
//尋找連接
val candidate = findConnection(
connectTimeout = connectTimeout,
readTimeout = readTimeout,
writeTimeout = writeTimeout,
pingIntervalMillis = pingIntervalMillis,
connectionRetryEnabled = connectionRetryEnabled
)
//確認(rèn)找到的連接可用并返回
if (candidate.isHealthy(doExtensiveHealthChecks)) {
return candidate
}
...
throw IOException("exhausted all routes")
}
}
@Throws(IOException::class)
private fun findConnection(
connectTimeout: Int,
readTimeout: Int,
writeTimeout: Int,
pingIntervalMillis: Int,
connectionRetryEnabled: Boolean
): RealConnection {
if (call.isCanceled()) throw IOException("Canceled")
// 1. 嘗試重用這個(gè)call的連接 比如重定向需要再次請(qǐng)求 那么這里就會(huì)重用之前的連接
val callConnection = call.connection
if (callConnection != null) {
var toClose: Socket? = null
synchronized(callConnection) {
if (callConnection.noNewExchanges || !sameHostAndPort(callConnection.route().address.url)) {
toClose = call.releaseConnectionNoEvents()
}
}
//返回這個(gè)連接
if (call.connection != null) {
check(toClose == null)
return callConnection
}
// The call's connection was released.
toClose?.closeQuietly()
eventListener.connectionReleased(call, callConnection)
}
...
// 2. 嘗試從連接池中找一個(gè)連接 找到就返回連接
if (connectionPool.callAcquirePooledConnection(address, call, null, false)) {
val result = call.connection!!
eventListener.connectionAcquired(call, result)
return result
}
// 3. 如果連接池中沒(méi)有 計(jì)算出下一次要嘗試的路由
val routes: List<Route>?
val route: Route
if (nextRouteToTry != null) {
// Use a route from a preceding coalesced connection.
routes = null
route = nextRouteToTry!!
nextRouteToTry = null
} else if (routeSelection != null && routeSelection!!.hasNext()) {
// Use a route from an existing route selection.
routes = null
route = routeSelection!!.next()
} else {
// Compute a new route selection. This is a blocking operation!
var localRouteSelector = routeSelector
if (localRouteSelector == null) {
localRouteSelector = RouteSelector(address, call.client.routeDatabase, call, eventListener)
this.routeSelector = localRouteSelector
}
val localRouteSelection = localRouteSelector.next()
routeSelection = localRouteSelection
routes = localRouteSelection.routes
if (call.isCanceled()) throw IOException("Canceled")
// Now that we have a set of IP addresses, make another attempt at getting a connection from
// the pool. We have a better chance of matching thanks to connection coalescing.
if (connectionPool.callAcquirePooledConnection(address, call, routes, false)) {
val result = call.connection!!
eventListener.connectionAcquired(call, result)
return result
}
route = localRouteSelection.next()
}
// Connect. Tell the call about the connecting call so async cancels work.
// 4.到這里還沒(méi)有找到可用的連接 但是找到了 route 即路由 進(jìn)行socket/tls連接
val newConnection = RealConnection(connectionPool, route)
call.connectionToCancel = newConnection
try {
newConnection.connect(
connectTimeout,
readTimeout,
writeTimeout,
pingIntervalMillis,
connectionRetryEnabled,
call,
eventListener
)
} finally {
call.connectionToCancel = null
}
call.client.routeDatabase.connected(newConnection.route())
// If we raced another call connecting to this host, coalesce the connections. This makes for 3
// different lookups in the connection pool!
// 4.查找是否有多路復(fù)用(http2)的連接,有就返回
if (connectionPool.callAcquirePooledConnection(address, call, routes, true)) {
val result = call.connection!!
nextRouteToTry = route
newConnection.socket().closeQuietly()
eventListener.connectionAcquired(call, result)
return result
}
synchronized(newConnection) {
//放入連接池中
connectionPool.put(newConnection)
call.acquireConnectionNoEvents(newConnection)
}
eventListener.connectionAcquired(call, newConnection)
return newConnection
}
接下來(lái)看看是如何建立連接的
fun connect(
connectTimeout: Int,
readTimeout: Int,
writeTimeout: Int,
pingIntervalMillis: Int,
connectionRetryEnabled: Boolean,
call: Call,
eventListener: EventListener
) {
...
while (true) {
try {
if (route.requiresTunnel()) {
//創(chuàng)建tunnel,用于通過(guò)http代理訪問(wèn)https
//其中包含connectSocket、createTunnel
connectTunnel(connectTimeout, readTimeout, writeTimeout, call, eventListener)
if (rawSocket == null) {
// We were unable to connect the tunnel but properly closed down our resources.
break
}
} else {
//不創(chuàng)建tunnel就創(chuàng)建socket連接 獲取到數(shù)據(jù)流
connectSocket(connectTimeout, readTimeout, call, eventListener)
}
//建立協(xié)議連接tsl
establishProtocol(connectionSpecSelector, pingIntervalMillis, call, eventListener)
eventListener.connectEnd(call, route.socketAddress, route.proxy, protocol)
break
} catch (e: IOException) {
...
}
}
...
}
建立tsl連接
@Throws(IOException::class)
private fun establishProtocol(
connectionSpecSelector: ConnectionSpecSelector,
pingIntervalMillis: Int,
call: Call,
eventListener: EventListener
) {
//ssl為空 即http請(qǐng)求 明文請(qǐng)求
if (route.address.sslSocketFactory == null) {
if (Protocol.H2_PRIOR_KNOWLEDGE in route.address.protocols) {
socket = rawSocket
protocol = Protocol.H2_PRIOR_KNOWLEDGE
startHttp2(pingIntervalMillis)
return
}
socket = rawSocket
protocol = Protocol.HTTP_1_1
return
}
//否則為https請(qǐng)求 需要連接sslSocket 驗(yàn)證證書(shū)是否可被服務(wù)器接受 保存tsl返回的信息
eventListener.secureConnectStart(call)
connectTls(connectionSpecSelector)
eventListener.secureConnectEnd(call, handshake)
if (protocol === Protocol.HTTP_2) {
startHttp2(pingIntervalMillis)
}
}
至此,創(chuàng)建好了連接,返回到最開(kāi)始的 find() 方法返回 ExchangeCodec 對(duì)象,再包裝為 Exchange 對(duì)象用來(lái)下一個(gè)攔截器操作。
3.6 CallServerInterceptor
這個(gè)類負(fù)責(zé)實(shí)質(zhì)的請(qǐng)求與響應(yīng)的 I/O 操作,即往 Socket ⾥寫(xiě)⼊請(qǐng)求數(shù)據(jù),和從 Socket ⾥讀取響應(yīng)數(shù)據(jù)。
總結(jié)
用一張 @piasy 的圖來(lái)做總結(jié),圖很干練結(jié)構(gòu)也很清晰。

以上就是Android okhttp的啟動(dòng)流程及源碼解析的詳細(xì)內(nèi)容,更多關(guān)于Android okhttp的啟動(dòng)流程的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
- Android基于OkHttp實(shí)現(xiàn)文件上傳功能
- Android 網(wǎng)絡(luò)請(qǐng)求框架解析之okhttp與okio
- Android使用OKhttp3實(shí)現(xiàn)登錄注冊(cè)功能+springboot搭建后端的詳細(xì)過(guò)程
- 解析Android框架之OkHttp3源碼
- Android OKHttp使用簡(jiǎn)介
- Android Okhttp斷點(diǎn)續(xù)傳面試深入解析
- Android使用OkHttp發(fā)送post請(qǐng)求
- Android基于OkHttp實(shí)現(xiàn)下載和上傳圖片
- Android內(nèi)置的OkHttp用法介紹
相關(guān)文章
Android 中TeaPickerView數(shù)據(jù)級(jí)聯(lián)選擇器功能的實(shí)例代碼
這篇文章主要介紹了Android TeaPickerView數(shù)據(jù)級(jí)聯(lián)選擇器 ,需要的朋友可以參考下2019-06-06
android MediaRecorder實(shí)現(xiàn)錄屏?xí)r帶錄音功能
這篇文章主要介紹了android MediaRecorder錄屏?xí)r帶錄音功能實(shí)現(xiàn)代碼,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-04-04
使用Android Studio實(shí)現(xiàn)為系統(tǒng)級(jí)的app簽名
這篇文章主要介紹了使用Android Studio實(shí)現(xiàn)為系統(tǒng)級(jí)的app簽名,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-03-03
Android開(kāi)發(fā)者常見(jiàn)的UI組件總結(jié)大全
Android開(kāi)發(fā)中UI組件是構(gòu)建用戶界面的基本元素,下面這篇文章主要給大家介紹了關(guān)于Android開(kāi)發(fā)者常見(jiàn)的UI組件總結(jié)的相關(guān)資料,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-04-04
android實(shí)現(xiàn)驗(yàn)證碼按鈕
這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)驗(yàn)證碼按鈕功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-07-07
解決RecyclerView無(wú)法onItemClick問(wèn)題的兩種方法
這篇文章主要介紹了解決RecyclerView無(wú)法onItemClick問(wèn)題的相關(guān)知識(shí),非常不錯(cuò),具有參考借鑒價(jià)值,感興趣的朋友一起看下吧2016-07-07

