android - catch asynctask ANR -


my downloadfile asynctask may need quite time in case of concurrent downloads on 2g networks. suspect killed off not sure.

my question is: timeout on asynctask , function called when android kills task? if exception thrown, catch it?

android shouldn't kill task. asynctask that, asynchronous, android not throw anrs it.

if want test exceptions within doinbackground, wrap code in relevent try catch blocks , throw or handle exceptions if , when arise.

you can cancel asynctask must check @ relavent intervals within task iscancelled flag.

once have cancelled task, onpostexecute() not called.

further reading of course available here: http://developer.android.com/reference/android/os/asynctask.html

addition: note, perhaps importantly android ice cream sandwich, , perhaps honeycomb shifted away thread pool execution default , use instead serialised approach. if find on ics tasks appear never executed, or executed after significant wait, should execute using executeonexecutor() , pass thread_pool_executor parameter. more information available @ above link.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -