asynchronous - Start Android activity when receiving the last response from multiple Volley requests -


in oncreate method of splashscreen, make 2 different volley requests :

requestqueue queue = appcontroller.getinstance().getrequestqueue(); gsonrequest<wpposts> myreq = new gsonrequest<wpposts>(urljson, wpposts.class, null,createmyreqsuccesslistener(),createmyreqerrorlistener()); queue.add(myreq); 

and 1 categories.

i start mainactivity when receive last response these 2 resquests :

private response.listener<wpposts> createmyreqsuccesslistener() {     return new response.listener<wpposts>() {         @override         public void onresponse(wpposts response) {...} 

regardless response arrives first or last.

would semaphorical approach ?

you don't need extend listeners or that.

you can set in splashscreen static int, increment in onresponse of these requests. onresponse delivered in main thread don't need worry threading issues here.

note want have value incemented onerror if error occurs never able go main activity :)


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -