Catch Error Exiting Memory in WebView?

When I load certain .swf files into WebView , a second after the flash file appears, my application closes with a Signal 11 error. No exception is thrown that I see. LogCat dump example here .

When downloading the same .swf files to an Android browser in the warehouse, an error icon is displayed instead of closing. Touching it opens a pop-up message: "Adobe Flash, not enough memory."

My question is: is there a way to catch the "Out of memory" error before SIGSEGV happens - preventing task completion - how does the stock browser do it? Any help would be greatly appreciated!


Note. I am testing the HTC Flash plugin under Android 2.2, but it seems that similar problems occur on devices other than HTC. I load the swf file into the WebView directly using:

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

(with plugins and JavaScript enabled). It works great in most cases - only a few files cause problems. I tried various suggestions to reduce memory (like clearing WebView caches) without success.

+2
source share
2 answers

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

, , :

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

boolean onLowMemory = memoryInfo.lowMemory;

memoryInfo.availMem, ( memoryInfo.threshold), .

+3

, onPause()

, . , killable. , . onDestroy() - , , , . onPause() killable, - . Activity

-1

All Articles