I have an Android application, written in Java. It uses a Java class that takes a few seconds to load (some .csv files and jars).
What is the idiomatic way to load that stuff?
I inherited the code, and right now it tries to load it in the background, but I think there are some race conditions causing bugs.
I just want a nice, synchronous, slow but reliable load (say, a splash screen) as the application starts.
I found many blog posts about implementing a splash screen.
Is there an official version?
The code that is loading in the background:
/**
* Initialize staticAnthro if it is null.
* This class loads CSV files, so do it in the background.
*/
static class InitInBackground extends AsyncTask<Void, Integer, Boolean> {
@NonNull
@Override
protected Boolean doInBackground(Void... arg0) {
startedInit = true;
try {
if (staticAnthro == null) {
staticAnthro = new Anthro();
}
} catch (IOException e) {
Log.e(LOGGER_TAG, "Error starting Anthro class", e);
}
return true;
}
}