When my app launches a file scraper that iterates recursively through the sdcard is kicked off. As you can imagine, this takes a fair amount of time. On my epad transformer it can take 30 to 40 seconds to blitz through the 32gb of storage.
This activity is done in two fragments that live on the main layout, launched from the main activity.
Obviously with load times like that I need to do something to alert the user. However, from what I've read I can't launch the main activity in the background behind a load screen. I've tried to drop a progress bar on and also failed.
So, any suggestions?
EDIT
I'm just reading up on using an aSyncTask within a fragment. I would love to use a progressbar, either within the slow list fragment, or on a splashscreen, or just over the main view
Do something like this
LoadTask load;
public class LoadTask extends AsyncTask<Void, Integer, Boolean> {
int prog = 0;
@Override
protected Boolean doInBackground(Void... params) {
//All your loading code goes in here
publishProgress(prog++); //Use this to update the progress bar
publishProgress(-1) //Use this to open other app
return false;
}
protected void onProgressUpdate(Integer... progress) {
if(progress[i] == -1)
//open other app here
for(int i = 0; i < progress; i++){
//set progress here with progress[i];
}
}
}
then to start the async task use
load = new LoadTask();
load.execute();