Java Android Webview:无法调用determinedVisibility() - 从未见过pid 的连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33083066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Webview: Cannot call determinedVisibility() - never saw a connection for the pid
提问by Laurens V
I have a Android Webview and when I click on a link to download a file (image of pdf etc) I got a error message.
我有一个 Android Webview,当我单击链接下载文件(pdf 图像等)时,我收到一条错误消息。
Error message:
Cannot call determinedVisibility() - never saw a connection for the pid
Any idea what I do wrong? Who can help please!?
知道我做错了什么吗?请问谁能帮帮忙!?
采纳答案by Burhan ARAS
Just a bit of configuration:
只是一点配置:
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDomStorageEnabled(true);
回答by Dennis Allert
I got the same error and Burhans solution was not helping me. I think things went wrong when you′re trying to load different urls too fast.
我遇到了同样的错误,Burhans 解决方案对我没有帮助。我认为当您尝试过快加载不同的 url 时出现问题。
Edit: Found a better solution credits go to user2652394 WebView must be loaded twice to load correctly
编辑:找到一个更好的解决方案学分转到 user2652394 WebView 必须加载两次才能正确加载
You have to do something like this:
你必须做这样的事情:
webView.postDelayed(new Runnable() {
@Override
public void run() {
webView.loadUrl(landingpage);
}
}, 500);
回答by AlexVPerl
I faced the same issue.
我遇到了同样的问题。
Was solved by giving a WebView a static height (ie 300dp) or specifying minHeight value.
通过为 WebView 提供静态高度(即 300dp)或指定 minHeight 值来解决。
回答by manuel
This is how I fixed a similar issue:
这是我解决类似问题的方法:
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view,String url) {
return false;
}
});
mWebView.loadURL(...
回答by Hessam J.E
This problem in my case produce by incorrect settings in layout properties. I had used:
在我的情况下,这个问题是由布局属性中的错误设置引起的。我曾经使用过:
<WebView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/webView"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="false"
android:layout_alignWithParentIfMissing="false" />
Instead of setting:
而不是设置:
<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/textView" />
The problems had been solved, when I removed "layout_alignParent" settings.
当我删除“layout_alignParent”设置时,问题已经解决。
回答by Manu Antony
Check whether internet permission is properly set on the Manifest file. Make sure that the permission tag should be outsideof your Application tag.
检查清单文件是否正确设置了互联网权限。确保权限标签应该在您的应用程序标签之外。
<uses-permission android:name="android.permission.INTERNET" />
Hope this might help some one.
希望这可能对某人有所帮助。
回答by kashyap jimuliya
Late to party, but might help some.
May sound silly as hell, but the mistake I made was not adding http://
in the beginning of the URL.
聚会迟到,但可能会有所帮助。可能听起来很傻,但我犯的错误是没有http://
在 URL 的开头添加。
回答by Bord81
I found a workaround by using onPageFinished
method instead of shouldOverrideUrlLoading
. It also provides the needed URL in the list of arguments.
我通过使用onPageFinished
method 而不是shouldOverrideUrlLoading
. 它还在参数列表中提供所需的 URL。
The only trick is to set a check so that the main logic of the method (in my case making a Toast) is not triggered when onPageFinished
gets called on the the page load itself.
唯一的技巧是设置一个检查,以便onPageFinished
在页面加载本身上调用时不会触发该方法的主要逻辑(在我的例子中是一个 Toast)。
回答by Jon Goodwin
Background
背景
Here is the source code of the methodin the browser enginethat gives the error(BindingManagerImpl.java), from Chromium source:
这里是源代码方法在浏览器引擎,使该误差(BindingManagerImpl.java),从铬源:
@Override
public void determinedVisibility(int pid) {
ManagedConnection managedConnection;
synchronized (mManagedConnections) {
managedConnection = mManagedConnections.get(pid);
}
if (managedConnection == null) {
Log.w(TAG, "Cannot call determinedVisibility() - never saw a connection for the pid: "
+ "%d", pid);
return;
}
Analysis
分析
It's a rendering warningfrom content.
这是来自内容的渲染警告。
Consecutivecalls to loadUrl
cause a race condition. The problem is that loadUrl("file://..")
doesn'tcomplete immediately, and so when you call loadUrl("javascript:..")
it will sometimes execute beforethe page has loaded.
连续调用loadUrl
导致竞争条件。问题是它loadUrl("file://..")
不会立即完成,因此当您调用loadUrl("javascript:..")
它时,有时会在页面加载之前执行。
Detail
细节
For more detail seethis stackoverflow answer.
有关更多详细信息,请参阅此stackoverflow 答案。
回答by qingsong xu
mWebView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition,
String mimetype, long contentLength) {
Log.d("download",url);
}
});