New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert AsyncTasks to IntentService #90

Open
wants to merge 14 commits into
base: master
from

Conversation

Projects
None yet
1 participant
@yulin2

yulin2 commented May 4, 2015

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.

@yulin2

This comment has been minimized.

Show comment
Hide comment
@yulin2

yulin2 May 15, 2015

I sent this pr several days ago. Any comments/suggestions on the changes?

yulin2 commented May 15, 2015

I sent this pr several days ago. Any comments/suggestions on the changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment