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(),
        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).
                            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;

        public void getDistances(double 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.