How to pass resp.getDistance() from calcPath method to a global variable?

resp.getDistance() is in the AsyncTask so i can’t pass the value to a declared global variable. How can i do it?

        private List<Double> distances;
        ...
        calcPath(start.getLatitude(), start.getLongitude(), geoPoints.get(0).getLatitude(),
                        geoPoints.get(0).getLongitude());
        logUser("Distance" + distances.get(0)); //throws an error
        ...
        public void calcPath(final double fromLat, final double fromLon,
                             final double toLat, final double toLon) {

            log("Calculating path ...");
            new AsyncTask<Void, Void, PathWrapper>() {
                float time;

                protected PathWrapper doInBackground(Void... v) {
                    StopWatch sw = new StopWatch().start();
                    GHRequest req = new GHRequest(fromLat, fromLon, toLat, toLon).
                            setAlgorithm(Algorithms.DIJKSTRA_BI);
                    req.getHints().
                            put(Routing.INSTRUCTIONS, "false");
                    GHResponse resp = hopper.route(req);
                    time = sw.stop().getSeconds();
                    return resp.getBest();
                }

                protected void onPostExecute(PathWrapper resp) {
                    if (!resp.hasErrors()) {
                        logUser(resp.getDistance() / 100 / 10f); //it has a value when it displays
                        getDistances(resp.getDistance() / 100 / 10f);
                    } else {
                        logUser("Error:" + resp.getErrors());
                    }
                    shortestPathRunning = false;
                }
            }.execute();
        }

        public void getDistances(double distance){
            distances.add(distance);
        }

What do you mean?
AsyncTask is an inner class, you can access the Activity from within.

Yeah, I just found out. Thank you anyway. I’ve find a different way to manipulate the data.