【发布时间】:2022-10-15 00:14:44
【问题描述】:
我对 Kotlin 语言还很陌生,我使用 okHttp3 来连接我的其他 API,它工作正常,但是我看到了一些 cmets,我开始使用改造而不是 okHttp。问题是,我需要将响应标头保存在我的 Global 类中,但是当我放入 response.header() 时,它说所需的类型是 retrofit2.http.Headers 并找到 okhttp3.Headers 即使我没有导入 okhttp我班上的模块。 有什么方法可以指定我要使用 Retrofit 标头?
那是我的 globalClass
package com.example.appfacul
import android.app.Application
import retrofit2.http.Headers
class GlobalClass:Application() {
var globalUserName = "test"
var email = ""
var id = ""
var responseHeaders = Headers()}
那是我想要获得标题的其他课程
override fun onResponse(
call: Call<AutenticationResponse>,
response: Response<AutenticationResponse>
) {
val globalClass = GlobalClass()
val resultHeader=response.headers()
globalClass.responseHeaders=resultHeader
其他类进口
这就是 ide 显示的错误
【问题讨论】:
标签: android kotlin retrofit okhttp conflict