My android app takes some time to initialize, and I'd like to show a splash image before the loading screen appears and hide it afterwards. I searched through stackoverflow and found some solutions. I tried to follow this tutorial, that explains how to implement a proper splash screen that starts within a splash activity, but it didn't solve my problem, because there was still a several seconds black screen between the splash screen and the loading screen (which renders from a separate thread of C++ code, and has to initialize a bunch of things before render starts, please don't ask to change that part, it's a crossplatform C++ engine). Next I experimented with a ProgressDialog taken from here, started it in onCreate of the main activity and hided when C++ part starts actual rendering, and it worked fine except not being a splash image. But the timing was exactly what I need. Then I replaced it with an ImageView and it didn't work (no image is shown).
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//...
mImageView = new ImageView(this);
mImageView.setScaleType(ScaleType.FIT_XY);
mImageView.setImageResource(R.drawable.splash_bg);
setContentView(mImageView);
}
splash_bg.png is put into res/drawable folder and shows fine from the splash activity. What is missing?