標籤:android style blog http color io os ar java
以android 4.2為例
1, android 4.2中 WebViewClassic.java 為 WebView.java的代理類.
2,程式運行後,瀏覽器首先載入webkit so.
WebViewCore.java ,apk 運行後只載入一次.
static {
// Load libwebcore and libchromium_net during static initialization.
// This happens in the zygote process so they will be shared read-only
// across all app processes.
try {
System.loadLibrary("chromium_net");
System.loadLibrary("webcore");
} catch (UnsatisfiedLinkError e) {
Log.e(LOGTAG, "Unable to load native support libraries.");
}
3,loadLibary 後則會初始化對應的JNI.將framwork 層webkit與c++ 層關聯對應起來.
主要處理在 WebCoreJniOnLoad.cpp
static RegistrationMethod gWebCoreRegMethods[] = {
{ "JavaBridge", android::registerJavaBridge },
{ "WebFrame", android::registerWebFrame },
{ "WebViewCore", android::registerWebViewCore },
{ "WebHistory", android::registerWebHistory },
{ "WebIconDatabase", android::registerWebIconDatabase },
{ "WebSettingsClassic", android::registerWebSettings },
#if ENABLE(DATABASE)
{ "WebStorage", android::registerWebStorage },
#endif
{ "WebView", android::registerWebView },
{ "ViewStateSerializer", android::registerViewStateSerializer },
{ "GeolocationPermissions", android::registerGeolocationPermissions },
{ "MockGeolocation", android::registerMockGeolocation },
#if ENABLE(VIDEO)
{ "HTML5Audio", android::registerMediaPlayerAudio },
{ "HTML5VideoViewProxy", android::registerMediaPlayerVideo },
#endif
{ "DeviceMotionAndOrientationManager", android::registerDeviceMotionAndOrientationManager },
{ "CookieManager", android::registerCookieManager },
{ "CacheManager", android::registerCacheManager },
};
4.建立WebView:
webview1= (WebView) findViewById(R.id.WebView1);
該行調用後,則會初始webkit,java 及c++層的關鍵類.
android webkit 初始化流程