Hi prey-android-client developers, I'm doing research on Android async programming, particularly on
AsyncTask and IntentService. AsyncTask can lead to memory leak and losing task result when GUI is recreated during task running (such as orientation change). This article describe the problems very well.
We discussed with some Android experts and they agree with this issue, and claim that AsyncTask can be considered only for short tasks (less than 1 second). However, using IntentService (or AsyncTaskLoader) can avoid such problems since their lifecycles are independent from Activity.
In prey-android-client, most of the AsyncTasks are declared as non-static inner classes of Activity/Preference. So the above issue can occur (especially for relatively long tasks).
I refactored 7 AsyncTasks in prey-android-client to IntentService (in 7 commits), with the help of a refactoring tool we developed. Do you think using IntentService should be better in these 7 scenario? Do you want to merge this pr? Thanks.
Hi prey-android-client developers, I'm doing research on Android async programming, particularly on AsyncTask and IntentService. AsyncTask can lead to memory leak and losing task result when GUI is recreated during task running (such as orientation change). This article describe the problems very well.
We discussed with some Android experts and they agree with this issue, and claim that AsyncTask can be considered only for short tasks (less than 1 second). However, using IntentService (or AsyncTaskLoader) can avoid such problems since their lifecycles are independent from
Activity
.In
prey-android-client
, most of the AsyncTasks are declared as non-static inner classes of Activity/Preference. So the above issue can occur (especially for relatively long tasks).I refactored 7 AsyncTasks in
prey-android-client
to IntentService (in 7 commits), with the help of a refactoring tool we developed. Do you think using IntentService should be better in these 7 scenario? Do you want to merge this pr? Thanks.