Ho una domanda che ho una schermata iniziale nella mia app per Android in cui sto usando thread per attendere 8 secondi, sta funzionando bene in 1.6,2.1,2.2,2.3 .3, 3.0, 3.1 ma restituisce errore quando voglio eseguire lo stesso nella versione 4.0.3 di Android, non so perché? Per favore suggeriscimi la soluzione giusta per lo stesso. Di seguito ho menzionato anche lo stack degli errori e il mio codice.Errore restituzioni thread in versione Android 4.0.3
Errore Stack:
01-05 10:16:06.417: E/AndroidRuntime(589): FATAL EXCEPTION: Thread-75
01-05 10:16:06.417: E/AndroidRuntime(589): java.lang.UnsupportedOperationException
01-05 10:16:06.417: E/AndroidRuntime(589): at java.lang.Thread.stop(Thread.java:1076)
01-05 10:16:06.417: E/AndroidRuntime(589): at java.lang.Thread.stop(Thread.java:1063)
01-05 10:16:06.417: E/AndroidRuntime(589): at com.shipface.common.SplashScreen$1.run(SplashScreen.java:34)
Codice: metodo
public class SplashScreen extends Activity {
/** Called when the activity is first created. */
Thread splash;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
splash = new Thread(){
@Override
public void run(){
try {
synchronized(this){
// Wait given period of time or exit on touch
wait(4000);
Intent intent = new Intent(SplashScreen.this,HomeActivity.class);
startActivity(intent);
finish();
}
}
catch(InterruptedException ex){
}
finish();
stop();
}
};
splash.start();
}
}