android - Executing Mutliple Queries In IntentService -


i have intentservice performs webservic call using retrofit, on success response (set of queries) executed. webservice call being made successfuly , well, when executing queries, ui freezes continues when execution finishes.

shouldnt intent service tasks in background without affecting ui?

code simplified:

@override public void success(response iu, response response) {     //get respose (set of queires loop on them , execute them.     (int = 0; < contentarray.length; i++) {         string query = contentarray[i];         mainactivity.mydatabase.execsql(query); }  //the amount of queries can reach 100 

if post more code

you appear making web service call using retrofit, , in particular, using retrofit callback. callback designed cases initiating query main application thread , want results delivered main application thread (e.g., update ui).

in case, none of true.

instead, drop callback , use retrofit's synchronous api. so, instead of like:

@get("/group/{id}/users") void grouplist(@path("id") int groupid, callback<list<user>> callback); 

use like:

@get("/group/{id}/users") list<user> grouplist(@path("id") int groupid); 

this way, results delivered on same thread on, synchronously, , ensure on background thread database i/o.

btw, if not doing already, consider wrapping database calls in transaction -- doing ~100 individual transactions may little slow.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -