English 中文(简体)
在 Android WebView 上获取 cound 显示显示的屏幕矩形错误
原标题:getBoundingClientRect error on Android WebView

我正为使用 Google 地图和地理定位的网站撰写一个包装程序。 我遇到的问题是, 在普通浏览器中, 页面功能通常正常, 但在 WebView 中, 两指缩放不起作用, 而这个错误的日志其实是 < 坚固 > floods < / 坚固 > :

05-24 08:14:28.504: E/Web Console( 2666): 未发现类型错误: 无法在 http:// <mydomain> /index.php:28 上读取属性获取无效的直径 ClientRect

问题是,这个功能只在谷歌JS代码中使用,而不是在我们的代码中使用,所以我对它没有太多权力。我应该如何开始解决这个问题呢?

以下是一些(可能)与你相关的消息来源,

myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebChromeClient(new WebChromeClient() {
    public void onProgressChanged(WebView view, int progress) {
        mk.setTitle(getString(R.string.loading));
        mk.setProgress(progress * 100);
        if(progress == 100) {
            mk.setTitle(R.string.app_name);
        }
    }

    public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
        callback.invoke(origin, true, false);
    }
});
myWebView.setWebViewClient(new MyWebViewClient());
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUserAgentString(getString(R.string.useragent));
webSettings.setGeolocationEnabled(true);
webSettings.setBuiltInZoomControls(false);
webSettings.setGeolocationDatabasePath("/data/data/com.mypackage.myapp");
myWebView.addJavascriptInterface(new JSInterface(this), "androidapp");
myWebView.loadUrl(HOMEURL);
问题回答

无论使用什么对象来称呼 getBoundingClientRect null -- 所以问题开始出现。 您可以查看原始的 JS 代码( 在网站上, 称之为 Google s API ) 吗?

在为网络视图设置自定义用户代理时,我遇到了这个问题。在我把它改为默认用户代理之后,问题就解决了。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签