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.
Error message:
Cannot call determinedVisibil
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.
mWebView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition,
String mimetype, long contentLength) {
Log.d("download",url);
}
});
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.
Edit: Found a better solution credits go to user2652394 WebView must be loaded twice to load correctly
You have to do something like this:
webView.postDelayed(new Runnable() {
@Override
public void run() {
webView.loadUrl(landingpage);
}
}, 500);
Here is the source code of the method in the browser engine that gives the error (BindingManagerImpl.java), from Chromium source:
@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;
}
It's a rendering warning from content.
Consecutive calls to loadUrl
cause a race condition. The problem is that loadUrl("file://..")
doesn't complete immediately, and so when you call loadUrl("javascript:..")
it will sometimes execute before
the page has loaded.
For more detail see this stackoverflow answer.
I found a workaround by using onPageFinished
method instead of shouldOverrideUrlLoading
. It also provides the needed URL in the list of arguments.
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.