Given that scripting is not natively supported in Android and wrapping libraries like javax.script.ScriptEngine into your app will make it too large, is it possible to send a javascript string to an invisible WebView and have it evaluate the string 开发者_如何学JAVAand return you the results (another string)?
I want to go this route because I want to save all my scripts to disk so my app can remain small.
Edit
I need Java code to evaluate javascript strings not the other way around. addJavascriptInterface() doesn't help.
Can it be done? Yes, via addJavascriptInterface()
and sending the browser a javascript:
URL, akin to a bookmarklet.
A far simpler answer, one that will use much less memory and will execute much faster, is to not use Javascript.
精彩评论