Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can fetch the http response from the remote url, parse it and replace the remote image urls with local ones via string replace. Then use this html code to display in the webview.</p> <blockquote> <p>I want to <strong>send down</strong> a webpage from a server to WebView</p> </blockquote> <p>Are you talking about 'push' rather than 'pull' mechanism (like as usual with <code>loadUrl()</code>)? That's only available in 2.2</p> <p>(Question: I guess working entirely with local web pages on the device doesn't work in your case, since you need updated versions from the server, right? You only know that the images won't change, correct?)</p> <p>Sample code for fetching a remote html page - afterwards you'd do the string replacement for your image urls:</p> <pre><code>/** * Downloads a remote file and stores it locally * @param from Remote URL of the file to download * @param to Local path where to store the file * @throws Exception Read/write exception */ static private void downloadFile(String from, String to) throws Exception { HttpURLConnection conn = (HttpURLConnection)new URL(from).openConnection(); conn.setConnectTimeout(15000); // timeout 15 secs conn.setDoInput(true); conn.connect(); InputStream input = conn.getInputStream(); FileOutputStream fOut = new FileOutputStream(to); int byteCount = 0; byte[] buffer = new byte[4096]; int bytesRead = -1; while ((bytesRead = input.read(buffer)) != -1) { fOut.write(buffer, 0, bytesRead); byteCount += bytesRead; } fOut.flush(); fOut.close(); } </code></pre> <p>Alternatively you could use</p> <pre><code>HttpClient httpClient = new DefaultHttpClient(); HttpGet get = new HttpGet("http://www.myurl.com"); HttpResponse res = httpClient.execute(get); if(res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { InputStream input = res.getEntity().getContent(); byte data[] = new byte[14]; input.read(data); .... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload