Pass image from HTML through javascript frontend on Android

My application is loading a small HTML document containing a single image in a webview. How can I get this image and use it as a Bitmap object in my application?

I am already using JavaScriptInterface along with my webview to get some other information like passing boolean data. Is it possible to pass an image also via JavaScriptIterface? Is this a good ideal or is there a better way?

+3


source to share


1 answer


Take a look at this question: Get image data in JavaScript?



You might be able to draw an image on a (presumably hidden) Canvas and then Base64-encode with toDataURL and pass that as a string through the JS interface, then decode it on the Java side. I guess it will be slow, but worth trying.

+2


source







All Articles