0

I want to get data from a server by Ion. I have this problem: just when run the project I can get data, but for other times I can not get any response. My code is:

public void GetData(final Context context, final String user_id){
    Ion.with(context)
       .load(Url+ "/user?")
        .setLogging("Data", Log.DEBUG)
       .setMultipartParameter("user_id", user_id)
       .asJsonObject()
       .setCallback(new FutureCallback<JsonObject>() {
           @Override
           public void onCompleted(Exception e, JsonObject result) {
               if(e == null){
                   List<String> messages = new ArrayList<String>();
                   String status = result.get(STATUS).getAsString();
                     if (status.equals(Success)) {
                       EventBus.getDefault().post(new mainClass.GetDataMessage(messages, status));
                   }
               }
           }
       });
}

When I debug it, it does not entry onCompleted() and comes out from Getdata. On LogCat there is this:

05-09 19:54:59.073 1278-1278/com.example.com D/Data: (۰ ms) http://URL?: preparing request
05-09 19:54:59.077 1278-1278/com.example.com I/Data: (۰ ms) http://:Url? Using loader: com.koushikdutta.ion.loader.HttpLoader@53cc2d6c
05-09 19:54:59.089 1278-1488/com.example.com D/Data: (۰ ms) http://Url?: Executing request.
AndroidDev
  • 701
  • 3
  • 9
  • 21
  • Partially as expected: It must come out of `GetData` because your code starts an asynchronous background process and has nothing else to do in the foreground process. - how did you test that it never enters `onCompleted`? PS: as per [docs](https://github.com/koush/ion), you could try enable logging `.setLogging("MyLogs", Log.DEBUG)` – zapl May 09 '16 at 19:11
  • I edited my questio when add .setLogging() in my code. – AndroidDev May 09 '16 at 20:11

0 Answers0