2

我正在开发一个使用 web 视图来显示地图的 Android 应用程序。性能还不错,我可以在没有更大延迟的情况下进行缩放/平移。但是启动需要不负责任的时间。(不加载页面!启动 webview ..)

这是我的 logcat 中的一个示例:

10-25 12:33:46.212: I opened the webview
10-25 12:34:03.062: onLoadResource() - the first JS file gets loaded
10-25 12:34:10.062: Page is fully loaded

所以在我看来,启动 webview 大约需要 17 秒,但加载页面只需要 7 秒。
知道问题可能是什么吗?

编辑:

 WebSettings settings = webview.getSettings();
 settings.setJavaScriptEnabled(true);
 settings.setGeolocationEnabled(true); 
 settings.setJavaScriptCanOpenWindowsAutomatically(true);
 settings.setDatabaseEnabled(true);
 settings.setRenderPriority(RenderPriority.HIGH);

 final Activity activity = this;
 webview.setWebChromeClient(new WebChromeClient() {
     public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
         callback.invoke(origin, true, false);
     }
 });
 webview.setWebViewClient(new WebViewClient() {
   public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
     Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
   }
   public void onLoadResource(WebView view, String url){
     System.out.println(url);

   }
 });

 webview.addJavascriptInterface(JavascriptInterface, "Android");
 webview.loadUrl("mywebpage");

 setContentView(webview);
4

0 回答 0