I have created a splash screen for my android app. My question is simple. After 5 seconds splash screen disappear and main activity works. Then if i click "Back" button it returns splash screen again. But i don't want this.
If user touch "Back" button on mainactivity, app must go android menu without splash screen. How can i fix it?
package com.example.androidfirst;
import android.app.Activity;
public class SplashActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
Thread timer = new Thread() { //new Thread
@Override
public void run() {
try {
sleep(5000);
}
catch (InterruptedException e) {
e.printStackTrace();
}
finally {
Intent MainAct = new Intent("com.example.androidfirst.MAINACTIVITY");
startActivity(MainAct);
try {
this.finalize();
}
catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};
timer.start();
}
}