且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android的使用V8没有的WebView

更新时间:2022-11-03 14:03:27

您可以创建通过其API的新V8引擎上下文,并用它来执行你的JavaScript,看看https://android.googlesource.com/platform/external/v8 包括目录,其中包含两个C ++头文件。链接对libwebcore.so(从https://android.googlesource.com/platform/external/webkit)通过NDK库,没什么特别的。

You can create a new V8 Context via its API and use that to execute your JavaScript, look into https://android.googlesource.com/platform/external/v8 include directory which contains two C++ header files. Link against the libwebcore.so (compiled from https://android.googlesource.com/platform/external/webkit) library via the NDK, nothing special.

v8::Persistent<v8::Context> context = v8::Persistent<v8::Context>::New(v8::Context::New());
context->Enter();

参见 https://developers.google.com/v8/get_started 的工作,并会在Android上。只要确保该设备实际上是附带了V8(一些较旧的设备附带JSC [JavaScript的核心])。

Refer to https://developers.google.com/v8/get_started which will work on Android. Just make sure the device actually ships with V8 (some older devices ship with JSC [JavaScript Core]).