I know that the team didn't want to provide s synchronous API for stringByEvaluatingJavaScriptFromString because the performance would be quite bad due to having to block on the WebCore thread. Why there is not async API, such as exposing the one you point out, I don't know :(.
That said, we are able to use the API you pointed out via reflection, and we should consider this as an option as well. The follow code does seem to work on Android 2.2 and 4.1: https://github.com/agrieve/incubator-cordova-android/commit/2400a63e8a64ab5e1d1de7bf30203eaed394781f If we go this route, we can still fall back on another technique if a future android version changes the private API it relies on. On Fri, Aug 10, 2012 at 10:41 AM, Jonathan Bond-Caron < [email protected]> wrote: > On Thu Aug 9 11:07 PM, Andrew Grieve wrote: > > > > Going Native->JS > > 1) Poll using 1) from above. (async) > > 2) Poll using 2) from above. (async) > > 3) Use loadUrl (breaks keyboard) (async) > > 4) Trigger an online/offline event and have JS pull in value using a > > sync > > JS->Native option (async) > > 5) Use a local server and hanging gets (async & complicated) > > > > Notes: > > -We currently use a combination of #1 and #5 > > -#3 is faster and simpler but breaks keyboard focus > > > > Out of curiosity, has anyone asked google why this is such a PITA? > > iOS has: UIWebView.stringByEvaluatingJavaScriptFromString > > The native java code binding to webkit already exists: > > https://github.com/android/platform_frameworks_base/blob/master/core/java/an > droid/webkit/WebViewCore.java#L1673<https://github.com/android/platform_frameworks_base/blob/master/core/java/android/webkit/WebViewCore.java#L1673> > > https://github.com/android/platform_external_webkit/blob/master/Source/WebKi > t/android/jni/WebCoreFrameBridge.cpp#L1489<https://github.com/android/platform_external_webkit/blob/master/Source/WebKit/android/jni/WebCoreFrameBridge.cpp#L1489> > > Yet google 'hides' this API? Anyone know why? > > >
