0

*the JsonObject json is empty, but result in onCompleted function works fine and correctly returns json data but I can't use it outside the oncompleted function *

   final JsonObject json = new JsonObject();
            Ion.with(MainActivity.this)
                    .load("https://wordsapiv1.p.mashape.com/words/" + searchedWord)
                    .setHeader("X-Mashape-Key","I've hidden the Key !")
                    .asJsonObject()
                    .setCallback(new FutureCallback<JsonObject>() {
                        @Override
                        public void onCompleted(Exception e, JsonObject result) {
                            Log.i("result: ","" + result);
                            Log.i("json: ", "" + json);
                        }
                    });
Muslem Omar
  • 1,021
  • 12
  • 12

1 Answers1

-1

I don't understand why you need the first line?

final JsonObject json = new JsonObject();
Khai Nguyen
  • 3,065
  • 1
  • 31
  • 24