android - splash screen wont destroy on press of back button -


i new android development , have finished first application university project. added in splash screen works perfectly, loads before main menu , switches after 3 seconds, if button pushed on phone during splash screen, taken out of application after 3 seconds passes main menu displayed. there way can application destroyed if button pushed during splash screen?

this splash.java file

public class splash extends activity {

    @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         requestwindowfeature(window.feature_no_title);         setcontentview(r.layout.splash);          thread splashtimer = new thread(){             public void run(){             try {                 sleep(3000);//3 seconds                 intent menuintent = new intent("com.example.main");                     startactivity(menuintent);                 }                    catch (interruptedexception e) {                     // todo auto-generated catch block                     e.printstacktrace();                 }                  {                         finish();                                    }             }         };         splashtimer.start();     } 

}

try:

@override public boolean onkeydown(int keycode, keyevent event) {   if (keycode == keyevent.keycode_back) {      finish();      return true;  }   return super.onkeydown(keycode, event); } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -