简体   繁体   中英

Call web service at splash using Aquery in android

I am using AQuery to call webservice for a couple of features in my app. For both cases, the AQuery uses two separate json files from server. Now how do I call both web services when splash screen is loading (given that internet is available)? Or do you suggest I use Async Task for this purpose? Please help!

You can try this. Just call another Aquery from inside the method of first Aquery.

AQuery aQueryFirst=new AQuery(getApplicationContext());
aQueryFirst.ajax(firstUrl, JSONArray.class, this, "jsonCallbackFirst");   
public void jsonCallbackFirst(String url, JSONArray array, AjaxStatus status) {
    if (array != null) {
        try {
           //Your code...
            }               
        } catch (Exception e) {     }
        AQuery aQueryNext= new AQuery(getApplicationContext());
        aQueryNext.ajax(nextUrl, JSONArray.class, this, "jsonCallbackNext");
    }
}

public void jsonCallbackNext(String nextUrl, JSONArray array, AjaxStatus status) {

    if (array != null) {
        try {
          //Your code...
            }               
        } catch (Exception e) { }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM