在web视图赶上闪现出内存不足的错误? [英] Catch Flash out-of-memory error in WebView?

查看:142
本文介绍了在web视图赶上闪现出内存不足的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

加载时一定瑞士法郎文件到一个的WebView ,一个分裂的Flash文件开始第二次后显示,我的应用程序与信号11故障关闭。没有异常被抛出,我可以看到。 例LogCat中转储这里

When loading certain .swf files into a WebView, a split second after the flash file begins to be displayed, my app closes with a Signal 11 fault. No exception is thrown that I can see. Example LogCat dump here.

当加载相同的瑞士法郎文件转换成股票Android浏览器,而不是关闭,则显示错误图标。触摸它会打开一个弹出窗口,说明:的Adobe Flash;内存不足

When loading the same .swf files into the stock Android browser, instead of closing, an error icon is displayed. Touching it opens a pop-up stating: "Adobe Flash; Insufficient Memory".

我的问题是:有没有办法在SIGSEGV发生之前捕捉内存不足错误 - preventing被终止的任务 - 这是由股票的浏览器呢?任何帮助将大大AP preciated!

My question is: Is there any way to catch the Insufficient Memory error before the SIGSEGV occurs -- preventing the task from being terminated -- as is done by the stock browser? Any help would be greatly appreciated!

注:我的Andr​​oid 2.2下测试的Flash插件的HTC版,但现在看来,同一类问题出现在其他非HTC设备。我直接加载SWF文件到web视图,使用:

Note: I'm testing under Android 2.2 with the HTC version of the Flash plugin, but it appears that the same sort of issues occur on other, non-HTC devices. I'm loading the swf file into the WebView directly, using:

webView.loadUrl("http://whatever.com/bla.swf");

(与插件和启用)。它完全在大多数情况下 - 只有少数文件会出现问题。我已经尝试了各种建议,以减少存储(如清除web视图缓存),但没有成功。

(with plugins and JavaScript enabled). It works perfectly in most cases -- only a few files cause problems. I've tried various suggestions for reducing memory (such as clearing the WebView caches) without success.

推荐答案

这是另一种解决方案是使用一个后台任务或服务来监控设备上的内存使用情况,如果系统告诉你,你在低内存,杀快闪活动。

An alternative solution could be to use a background task or service to monitor the memory usage on the device, if the system tells you that you're on low memory, kill the flash activity.

要知道,如果你是在低内存,你可以使用这个code:

To know if you are on low memory you can use this code:

ActivityManager activityManager = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
MemoryInfo memoryInfo = new ActivityManager.MemoryInfo(); 
activityManager.getMemoryInfo(memoryInfo);

boolean onLowMemory = memoryInfo.lowMemory;

或者你也可以使用检查可用内存的 memoryInfo.availMem 的,如果它太低(接近的 memoryInfo.threshold 的)杀除之前,你的活动。

Or you can check the available memory using memoryInfo.availMem, if it's too low (close to memoryInfo.threshold) kill your activity before the exception.

这篇关于在web视图赶上闪现出内存不足的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆