val retrofit = Retrofit.Builder() .baseUrl("http://10.0.2.2/") .addConverterFactory(GsonConverterFactory.create()) .build() val appService = retrofit.create(AppService::class.java) appService.getAppData().enqueue(object : Callback<List<App>> { overridefunonResponse(call: Call<List<App>>, response: Response<List<App>>) { val list = response.body() if (list != null) { for (app in list) { Log.d(TAG, "id is ${app.id}") Log.d(TAG, "name is ${app.name}") Log.d(TAG, "version is ${app.version}") } } }
// POST http://example.com/data/create // {"id":1,"content":"The description for this data."} @POST("data/create") funcreateData(@Bodydata: Data): Call<ResponseBody>