- The first splashscreen hidden after 5 secondes.
- I want to add a second splashscreen like the first before enter in MainActivity.
- in @drawable/background_1 <= This is the first image splashscreen I added.
- in @drawable/background_2 <= I need to add this image in second splashscreen.
splash.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_1" >
</RelativeLayout>
SplashScreen.java
package org.sbynight.app;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
public class SplashScreen extends Activity {
private static String TAG = SplashScreen.class.getName();
private static long SLEEP_TIME = 5; // Sleep for some time
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes title bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Removes notification bar
setContentView(R.layout.splash);
// Start timer and launch main activity
IntentLauncher launcher = new IntentLauncher();
launcher.start();
}
private class IntentLauncher extends Thread {
@Override
/**
* Sleep for some time and than start new activity.
*/
public void run() {
try {
// Sleeping
Thread.sleep(SLEEP_TIME*1000);
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
// Start main activity
Intent intent = new Intent(SplashScreen.this, MainActivity.class);
SplashScreen.this.startActivity(intent);
SplashScreen.this.finish();
}
}
}
Aucun commentaire:
Enregistrer un commentaire