Tag: 改造

如何从函数onResponse of Retrofit返回值?

我正在尝试返回我在retrofit调用请求中从onResponse方法获得的值,是否有一种方法可以从覆盖的方法中获取该值? 这是我的代码: public JSONArray RequestGR(LatLng start, LatLng end) { final JSONArray jsonArray_GR; EndpointInterface loginService = ServiceAuthGenerator.createService(EndpointInterface.class); Call call = loginService.getroutedriver(); call.enqueue(new Callback() { @Override public void onResponse(Response response , Retrofit retrofit) { jsonArray_GR = response.body().getRoutes(); //i need to return this jsonArray_GR in my RequestGR method } @Override public void onFailure(Throwable t) { } }); return […]