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