0
我有一個顯示逐幀動畫活動的Android應用程序。在動畫結束時,它啓動後臺服務並關閉活動。這裏是代碼:Android應用程序不會再運行
cont = getApplicationContext();
final ImageView img = (ImageView)findViewById(R.id.img);
img.setBackgroundResource(R.drawable.intro);
img.post(new Runnable() {
public void run() {
animation = (AnimationDrawable)img.getBackground();
animation.setOneShot(true);
animation.start();
timer = new Timer();
timer.schedule(new timer_exp(), 3400);
}
});
}
class timer_exp extends TimerTask{
@Override
public void run() {
//start service
Intent serviceIntent = new Intent(cont, MainService.class);
startService(serviceIntent);
//kill activity
finish();
}
}
當我運行應用程序,我可以看到動畫,然後服務啓動。當我再次按下應用程序的圖標時,出現黑屏,應用程序崩潰。
任何想法可能是什麼問題?
感謝, PB
LogCat中的輸出是什麼?提到的任何異常? – RvdK
當我第二次按下圖標時,LogCat上什麼都沒有。 –
如果它崩潰,那麼你會在LogCat中得到一些東西。再看一次 – wnafee