I start studying this: Android SplashScreen
and my app works perfectly with this method.
Unfortunately, I’ve developed a custom splash screen (not a progress dialog like in the other post) and I’m not able to use the same approach. My splashscreen is a different activity that I starts calling it from the onCreate as a different thread.
Instead of this.pd = ProgressDialog.show(this, "Working..", "Downloading Data...", true, false); in the onCreate I do:
Thread splashThread = new Thread() {
@Override
public void run() {
// start the splash screen activity
}
};
splashThread.start();
}
The splashscreeen activity correctly starts.
So I call the AsyncTask as in the default method (doInBackground, onPostExecute) and I’m not able to end the activity that is running the splashscreen and come back to the main one, after all the variables are loaded in the doInBackground.
Any suggestion?
Well, I finally thank JPM for the suggestion to use handlers and I solved with that:
In the MainActivity I manage handlers back and forth:
In this manner I can manage the doTheHeavyJob() function and finish the SplashScreen in both cases: after the job finish and at least after 3000 millis, the minimum duration of my splashscreen to be shown.
I also want to tank Teskio on the anddev italian website for the most of the job done here.