My application has 3 activities-Main menu, sub menu, detail. Every time the APPLICATION resumes, I want to get some intimation so that I can start downloading some files.
Right now what i am doing is- on each activity onResume, i check if downloading is already going on or not. If it isn’t then i start downloading. This way, whenever i start next/previous activity, if the downloading is not going on, it starts downloading. Meaning, once downloading was completed, user navigates to next page, downloading started again.
I want to prevent this behaviour otherwise there will be unnecessary internet usage.
If i maintain a global (application level) variable which keeps a track of download state, even after i resume the application, the value is not re-set.
Any suggestion as to how to get the onResume of application.
Well how about checking for the downloaded content before starting the download process? There’re multiple ways to do this, you didn’t provide much details on the nature of the content to download.
For example: check for the downloaded file in the FS, set a persistent flag somewhere (using SharedPreferences, SQLite db, whatever) that marks if the content is already downloaded, etc.