The First Screen Of Our App is Splash Screen. Use of this Splash Screen is to make the look Professional.
SplashActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| package com.ramesh.taskearnerexample;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
public class SplashActivity extends AppCompatActivity {
private static int SPLASH_TIME = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
//Code to start timer and take action after the timer ends
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//Do any action here. Now we are moving to next page
Intent mySuperIntent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(mySuperIntent);
/* This 'finish()' is for exiting the app when back button pressed
* from Home page which is ActivityHome
*/
finish();
}
}, SPLASH_TIME);
}
}
|