我遇到與我的應用程序4.x設備的問題。它看起來像一個線程正在使其崩潰,同時改變活動(從啓動畫面到實際應用程序)。下面是截圖:Android:UnsupportedOperationException與線程
飛濺活動代碼:
public class Splash extends Activity {
protected boolean _active = true;
protected int _splashTime = 3000; // tempo di permanenza spash screen
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread splashTread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
while(_active && (waited < _splashTime)) {
sleep(100);
if(_active) {
waited += 100;
}
}
} catch(InterruptedException e) {
// do nothing
} finally {
finish();
Intent i = new Intent(Splash.this, Test01Activity.class);
startActivity(i);
stop();
}
}
};
splashTread.start();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
_active = false;
}
return true;
}
}
此外,應用好好嘗試一下真正的崩潰,作爲主要的活動一直在後臺運行(後面的「不幸的是,應用程序已停止工作「警報)。這個問題只發現在4.x設備上,2.x和3.x全部正常。錯誤是在第37行。
究竟哪裏崩潰?請粘貼您的LogCat。 – 2012-07-19 08:37:08
在哪一行崩潰 – 2012-07-19 08:38:18
您的代碼似乎與此主題中的代碼相同:http://stackoverflow.com/q/4414737/517561 – Sparky 2012-07-19 08:40:13