I have an Android app where I’ve extended the base Application class in order to set up some global variables.
public class MyApplication extends Application {
private ArrayList<ModelClass> master_list; // global variable 1
private DataBaseHelper db_helper; // global variable 2
@Override
public void onCreate() {
super.onCreate();
//do database work that will take about 5 seconds
}
}
I’d like to show a splash screen to the user while the Application class is working (i.e. before my Main Activity is created). Is there a way to do this?
You could make the SplashActivity your start activity.
When MyApplication has completed it’s work you could start your main activity and dispose the splash screen.
But don’t do the heavy database work in onCreate, create another function and do it there, otherwise your splash activity won’t be shown.