Showing Logo 3 Seconds Before Loading Mainactivity
I want to make a logo (an own activity)show in an own activity 3 seconds before the main activity loads, when starting my android app. Which is the simplest approach for doing thi
Solution 1:
I think what you're referring is how to implement a Splash screen,
Create a new empty activity, I'll call it Splash for this example;
publicclassSplashScreenextendsActivity {
// Sets splash screen time in milisecondsprivatestaticintSPLASH_TIME=3000;
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
newHandler().postDelayed(newRunnable() {
@Overridepublicvoidrun() {
// run() method will be executed when 3 seconds have passed//Time to start MainActivityIntentintent=newIntent(Splash.this, MainActivity.class);
startActivity(intent );
finish();
}
}, SPLASH_TIME);
}
}
Make sure you've set Splash activity as the launcher activity in your Manifest file :
<activityandroid:name=".Splash"android:theme="@android:style/Theme.NoTitleBar"><intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter></activity>
Post a Comment for "Showing Logo 3 Seconds Before Loading Mainactivity"