大名鼎鼎的OkHttp?
0.9、添加網(wǎng)絡(luò)權(quán)限
<uses-permission android:name="android.permission.INTERNET" />
1、先導(dǎo)入依賴文件
implementation "com.squareup.okhttp3:okhttp:4.4.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.4.0"? ?//日志攔截依賴?幫我們打印日志
2、封裝請求網(wǎng)絡(luò)方法
------單例模式
? ? ? 構(gòu)造方法私有化

------get? 請求方法? ?需Handler?切換主線程?回調(diào)數(shù)據(jù)
? ? ? ? 1 .構(gòu)建請求

? ? ? ? ? ?2 .創(chuàng)建Call對象

------POST? 請求方法? ?需Handler?切換主線程?回調(diào)數(shù)據(jù)
? ? FormBody?存放請求體中的鍵值對數(shù)據(jù)
? ? RequestBody? 請求體


接口回調(diào)傳值
------接口回調(diào)
