I am attempting to create a splash screen to show up while my app initializes, using the dialog method discussed here:
http://blog.iangclifton.com/2011/01/01/android-splash-screens-done-right/
Yet, no matter what I do, the splash screen never appears, the screen just stays black until the main screen fully instantiates.. I call m.dismiss() at the end of the setup() method.
No errors are thrown, and the launch.XML is simply a linearlayout with a match_parent width and height and with a button taking up the enti view, but it never appears..
I assume it is either the context of “THIS” should be something else, or the width/height should be something other than match parent… any ideas/help would be appreciated.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
m = new Dialog(this,R.style.SplashScreen);
m.setContentView(R.layout.launch);
m.setCancelable(false);
m.show();
setContentView(R.layout.main);
Handler h = new Handler();
h.post( new Runnable(){
public void run() {
// TODO Auto-generated method stub
setup();
}
});
LAUNCH.XML file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button android:text="Button" android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/button1"></Button>
</LinearLayout>
your setup method is run on the UI thread. it prevents the spashscreen from being displayed. Try using an asynctask for the setup, and dismiss the splash in the onPostExecute()