0
我有一個帶有兩個圖像的OpenGL遊戲,一個是紋理圖集,另一個是單個圖像。當我嘗試打開一個OpenGL對象時,應用程序關閉時就會死掉。 代碼:Android應用程序在關閉InputStream時死亡
InputStream is = context.getResources().openRawResource(texture);
Bitmap bitmap = null;
try {
bitmap = BitmapFactory.decodeStream(is);
} finally {
try {
is.close();
is = null;
Log.i("log", "try");
} catch (IOException e) {
Log.i("log", "Catch");
}
}
它解碼的InputStream,但收盤後踏入陷阱。我真的不明白是什麼問題。使用其他紋理打開和關閉InputStreams正常工作。
我敢打賭,有一些很好的線索,在堆棧跟蹤這個問題的根源,嘗試記錄堆棧跟蹤:Log.i(「log」,「Catch」,e); – 2012-01-04 17:21:37
這是發生在模擬器上嗎? – 2012-01-04 17:24:28
「e」沒有任何反應,LogCat只寫出「Catch」。 R.daneel.olivaw:不,它發生在模擬器和手機上(沃達豐845)。關閉後,catch中的步驟出現LogCat中的許多DEBUG消息,並且應用程序死亡。 – matthew3r 2012-01-04 17:26:17