Android : how to call synchronous webservice in java or increase the value i after getting webservice response?

on Monday, November 3, 2014


I am send post request in loop like ..I am giving you psedo code .Actually I need some basic example for synchronise call .In other word in my example 10 request fire simultaneously and get the web service result.Is there any way to call synchronised type.Mean I need to increase value of I when I get the web service response ..when I=0 it call web service and get response then it increase the value .i=1 .Not send all request simultaneously .send step by step .



for (int i=0;i<10 ;i++){
//get data from data base
//get data from data base using i
JsonObject data =SELECT from Data* where ID=i
//call post request in another thread
callpostresquest(data)

}


callpostresquest(JsonObject onj){


Thread t=new Theard(){
run (){
// call web service when I got response I call back one method
callback(respone);
}

}t.start()
}


// call method in main screen



getWebserviceresponse (String response){

//get the wevservice response ..Then I need to increase value of i variable here how ?


}

0 comments:

Post a Comment