android - Optimizing loading speed AsyncTask -
in app use asynctask load text , images not more not less. it's done loading in second , other times can take 5minutes. have used asynctask because there lot of information in concerning situation.
now assume reason faster , slower loading has internet. came across line on android documents saying :
asynctask designed helper class around thread , handler , not constitute generic threading framework. asynctasks should ideally used short operations (a few seconds @ most.)
so using right? if not should use , useful articles on it. have been googling network best practices have not found detailed documentation explaining options , when use them etc.
an example of tutorial have used : http://android-developers.blogspot.nl/2010/07/multithreading-for-performance.html
indeed asynctask
not designed 5 minute long execution times, looking @ tutorial linked appears there no timeout values set http connection.
url url = new url("http://tpbapp.com"); connection.setconnecttimeout(1000); // 1 sec timeout open connection connection.setreadtimeout(3000); // 3 sec timeout load data
you can of course adjust these values depending on approximate size of data, although i've found setting connect timeout greater 1 sec images can interfere effectiveness of cancelling asynctask
. have written blog post (scroll bottom).
Comments
Post a Comment