Android Webview not showing specific page
07:39 14 Jul 2015

I'm using a Webview on my app to load a web page. Other web pages are working fine, this one seems to load but then shows a blank page.

The source code of the html page is generated by a CGI and the output is:






/*
 * This CSS stylesheet defines the rules to be applied to any ImageDocuments,
 * including those in frames.
*/

@media not print {
  .overflowing {
    cursor: zoom-out;
  }

  .shrinkToFit {
    cursor: zoom-in;
  }
}

@media print {
  img {
    display: block;
  }
}



@media not print {
  body {
    margin: 0;
  }

  img {
    text-align: center;
    position: absolute;
    margin: auto;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }

  .completeRotation {
    transition: transform 0.3s ease 0s;
  }
}

img {
  image-orientation: from-image;
}


Filtered chrome url chrome://global/skin/media/TopLevelImageDocument.css

CGI_GetImage.cgi (immagine JPEG, 640 × 480 pixel) - Riscalata (86%)





In my app I load the URL using this settings to my Webview:

    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setUseWideViewPort(true); // Alstro tried without this...

I think it might be some kind of problem with the CSS of the page but unfortunately I CAN NOT edit the output of the CGI generating the html.

Any help?

EDIT:

Here's how I load the URL:

webView = (WebView)findViewById(R.id.webViewPuntamento);
webView.setWebViewClient(new PuntamentoWebviewClient());
webView.loadUrl(getUrlPuntamento());

where PuntamentoWebviewClient() is an extension of WebviewClient which handles both basic http authentication and connection errors received from the server. getUrlPuntamento() simply returns the URL I'm gonna open.

Fact is I can load and see any other pages, except this one. I get no errors and I can show by a Toast the title of the loaded page, but no contents.

getUrlPuntamento() returns http://USER:PASSWORD@HOST_IP:PORT/cgi-bin/CGI_GetImage.cgi since the page require basic authentication.

In addition I use webView.setHttpAuthUsernamePassword(HOST, "Embedded-Device", USERNAME, PASSWORD); before loading the url.

and my PuntamentoWebviewClient() has this

@Override
public void onReceivedHttpAuthRequest(WebView view, @NonNull HttpAuthHandler handler, String host, String realm) {
   handler.proceed(USERNAME, PASSWORD);
}

The CGI is on an embedded device which I try to contact by direct connection to its wifi (this connection works fine). Connecting to the configuration page of the device (same authentication, same IP, different CGI) seems to work fine.

android html webview