android:decodeFile方法中的java.io.FileNotFoundException(打开的文件太多)

发布于 2025-01-07 04:20:44 字数 337 浏览 6 评论 0原文

我正在做图像的实时观看流。

我意识到,在运行我的程序大约几分钟后,应用程序将自行关闭,并出现以下窗口错误:java.io.FileNotFoundException(打开的文件太多)

跟踪logcat输出,错误发生在这一行附近:

Bitmap bitmap = BitmapFactory.decodeFile(file, bmpFactoryOptions);

我看到有一些类似的问题,但没有提供太多解决方案。

由于错误是我由于这个decodeFile方法而打开了太多文件,所以我有什么方法可以关闭这个文件引用吗?

谢谢大家!

i am doing a liveview streaming of image.

i realised that after running my program for around few minutes, the application will close by itself with the following window error: java.io.FileNotFoundException (Too many open files)

tracing the logcat output, the error happen at around this line:

Bitmap bitmap = BitmapFactory.decodeFile(file, bmpFactoryOptions);

i see that there a few similar question but it do not provide much solution.

since the eorror is i am opening too much files because of this decodeFile method, is there any way for me to close this file reference?

thanks all!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱娆 2025-01-14 04:20:44

您可以做的是自己打开文件,将输入流传递给 BitmapFactory 的decodeStream 方法,然后自己关闭文件。

What you could do is open the file yourself, pass the inputstream to the decodeStream method of BitmapFactory, then close the file yourself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文