我用改造抓取的数据没有出现在 logcat
The data that i grab with retrofit does not appear in logcat
嗨,我正在用 API 编写一个加密货币应用程序。我正在使用改装从互联网上获取数据我想我做的一切都是正确的,但数据没有出现在我的 logccat 中
我的主要 activity 是 ->
class MainActivity : AppCompatActivity() {
private val BASE_URL = "https://api.nomics.com/v1/"
private var cryptoModels: ArrayList<CryptoModel>? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//API Key : b358142f3857509cc2fb3f834b566dc8716cad4d
//https://api.nomics.com/v1/prices?key=b358142f3857509cc2fb3f834b566dc8716cad4d
loadData()
}
private fun loadData() {
val retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
val service = retrofit.create(CryptoAPI::class.java)
val call = service.getData()
call.enqueue(object : Callback<List<CryptoModel>> {
override fun onResponse(
call: Call<List<CryptoModel>>,
response: Response<List<CryptoModel>>
) {
if (response.isSuccessful) {
response.body()?.let {
cryptoModels = ArrayList(it)
for (cryptoModel: CryptoModel in cryptoModels!!) {
println(cryptoModel.currency)
println(cryptoModel.price)
}
}
}
}
override fun onFailure(call: Call<List<CryptoModel>>, t: Throwable) {
}
})
}
而我的改装界面是->
interface CryptoAPI {
//https://api.nomics.com/v1/
// prices?key=b358142f3857509cc2fb3f834b566dc8716cad4d
@GET ("prices?key=b358142f3857509cc2fb3f834b566dc8716cad4d")
fun getData (): Call<List<CryptoModel>>
已通过从模拟器卸载并重新安装应用程序修复
嗨,我正在用 API 编写一个加密货币应用程序。我正在使用改装从互联网上获取数据我想我做的一切都是正确的,但数据没有出现在我的 logccat 中 我的主要 activity 是 ->
class MainActivity : AppCompatActivity() {
private val BASE_URL = "https://api.nomics.com/v1/"
private var cryptoModels: ArrayList<CryptoModel>? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//API Key : b358142f3857509cc2fb3f834b566dc8716cad4d
//https://api.nomics.com/v1/prices?key=b358142f3857509cc2fb3f834b566dc8716cad4d
loadData()
}
private fun loadData() {
val retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
val service = retrofit.create(CryptoAPI::class.java)
val call = service.getData()
call.enqueue(object : Callback<List<CryptoModel>> {
override fun onResponse(
call: Call<List<CryptoModel>>,
response: Response<List<CryptoModel>>
) {
if (response.isSuccessful) {
response.body()?.let {
cryptoModels = ArrayList(it)
for (cryptoModel: CryptoModel in cryptoModels!!) {
println(cryptoModel.currency)
println(cryptoModel.price)
}
}
}
}
override fun onFailure(call: Call<List<CryptoModel>>, t: Throwable) {
}
})
}
而我的改装界面是->
interface CryptoAPI {
//https://api.nomics.com/v1/
// prices?key=b358142f3857509cc2fb3f834b566dc8716cad4d
@GET ("prices?key=b358142f3857509cc2fb3f834b566dc8716cad4d")
fun getData (): Call<List<CryptoModel>>
已通过从模拟器卸载并重新安装应用程序修复