Ho implementato lo splash screen per una mia app Android seguendo il libro Android Cookbok della O'Reilly. La splash screen rimane visibile per due secondi e dopo avvia l'applicazione vera e propria
Quando la App viene avviata funziona perfettamente.codice:public class SplashApp extends Activity { /** * number of millisecond the splash is displayed before starting the main Activity */ public static final int SPLASH_DELAY = 2000; private long ms=0; private boolean splashActive = true; private boolean paused=false; /** Called when the activity is first created. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash_screen); Thread mythread = new Thread() { @Override public void run() { try { while (splashActive && ms < SPLASH_DELAY ) { if(!paused) ms=ms+100; sleep(100); } } catch(Exception e) {} finally { Intent intent = new Intent(SplashApp.this, MyApp.class); startActivity(intent); } } }; mythread.start(); } }
Il problema e' che quando esco dalla Activity principale (MyApp) tramite il back button,
l'app non esce ma torna sullo splash screen e devo premere il bottone un'altra volta per farla uscire.
Qualche idea su come fare uscire direttamente la mia App senza passare per lo splash screen ?

Rispondi quotando
