I would like to display a splash screen while everything is initializing in the onCreate() method, yet components that I need to draw things to the screen are also initializing, therefore there's a black screen when I start the app and after the onCreate() method has completed then only is the first screen drawn. Instead of having the black screen I'd like a splash screen.
Here's my code in the onCreate method:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Acquire a wakeLock to prevent the phone from sleeping
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "GLGame");
// Setup all the Game Engine components
gameEngineLog = new WSLog("WSGameEngine");
gameEngineLog.setLogType(this.gameEngineLogType);
gameLog = new WSLog(this.gameLogTAG);
gameLog.setLogType(this.gameLogType);
io = new FileIO(this, getAssets());
audio = new Audio(this);
wsScreen = new WSScreen(this, this.screenResizeType, this.customTopYGap, this.customLeftXGap, this.gameScreenWidth, this.gameScreenHeight);
graphics = new Graphics(this, wsScreen.getGameScreen(), wsScreen.getGameScreenextended());
renderView = new RenderView(this, wsScreen.getGameScreen(), wsScreen.getGameScreenextended(), FPS, maxFrameskippes);
input = new Input(this, renderView, logGameEngineInputLog);
setContentView(renderView);
if(useOfAnalytics == true) {
getGameEngineLog().w(classTAG, "Analytics has been enabled");
analytics = new Analytics(this);
}
// Check that the developer has initialized the assets
if(this.assets == null) {
this.gameEngineLog.w(classTAG, "The assets for the game haven't been defined!");
}
}
How should I implement a splash screen, to avoid the black screen at the beginning?