Android开发问题集锦五--OkHttp资源释放与内存泄露

Android开发问题集锦五--OkHttp资源释放与内存泄露

程序之美

OkHttp这里就不过多介绍了,在网络框架界可为家喻户晓,很多网络框架都是基于OkHttp封装的,也有很多第三方框架都和OkHttp兼容,在我们做网络通信的时候,OkHttp基本上起着挑大梁的作用。
下面简单说下其调用过程,熟知的朋友都知道,OkHttp调用很简单,只需要以下简单的几步。
1.引入库

在Android Studio工程的build.gradle中加入如下依赖就可以了。

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    implementation 'com.squareup.okhttp3:okhttp:3.8.1'
}

implementation ‘com.squareup.okhttp

Guess you like

Origin blog.csdn.net/hnjzfwy/article/details/120863801