first you need to have 2 xml file. one is for you flash screen, and the other is for your main
flash.xml
main.xml
SplashScreen.java
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.MotionEvent; public class SplashScreen extends Activity { protected boolean _active = true; protected int _splashTime = 5000; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); // thread for displaying the SplashScreen Thread splashTread = new Thread() { @Override public void run() { try { int waited = 0; while(_active && (waited < _splashTime)) { sleep(100); if(_active) { waited += 100; } } } catch(InterruptedException e) { // do nothing } finally { finish(); Intent i = new Intent(getApplicationContext(),MyApp.class); startActivity(i); stop(); } } }; splashTread.start(); } @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { _active = false; } return true; } }
package com.droidnova.android; import android.app.Activity; import android.os.Bundle; public class MyApp extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }
you will missing the drawable image so copy this image and pass it in your res/drawable
flash.jpg |
your Manifest.xml
0 comments:
Post a Comment