By Magesh Kumar
Posted at 3:24 AM
Android
Android just got splashed
The following code will show you how to create a basic splashscreen for your Android application that will stay for 5 seconds. If we don't want to wait we can tap the screen to go directly to the next Activity. Source project is on the bottom of the tutorial.
Lets go through the code to see how simple it is to make a very basic splash screen for your application.
The splashscreen will be the startup Activity for our application and on application launch a Thread will start that will listen for touch events.
01 | public class SplashScreen extends Activity { |
04 | protected int _splashTime = 5000 ; |
06 | private Thread splashTread; |
08 | /** Called when the activity is first created. */ |
10 | public void onCreate(Bundle savedInstanceState) { |
11 | super .onCreate(savedInstanceState); |
12 | setContentView(R.layout.splash); |
14 | final SplashScreen sPlashScreen = this ; |
17 | splashTread = new Thread() { |
27 | } catch (InterruptedException e) {} |
32 | Intent i = new Intent(); |
33 | i.setClass(sPlashScreen, Main. class ); |
46 | public boolean onTouchEvent(MotionEvent event) { |
47 | if (event.getAction() == MotionEvent.ACTION_DOWN) { |
48 | synchronized (splashTread){ |
49 | splashTread.notifyAll(); |
If you have questions just let me know
About the Author
Nulla sagittis convallis arcu. Sed sed nunc. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.
View all posts by: BT9
0 comments: