Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 992059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:12:19+00:00 2026-05-16T06:12:19+00:00

I want to send down a webpage from a server to WebView components on

  • 0

I want to send down a webpage from a server to WebView components on Android handsets.
I’ve already learned how to enable the webpage to talk to the JavaScript handler, so the native application can interact with the webpage.
I am, however, stuck on images.

I want the webpage that comes from a server to somehow tell the app which image (stored in either res or in assets) to load. This way I don’t have to send the image over the wire as well. Is this doable? It will make the process of loading WebView pages so much faster for my purposes.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:12:19+00:00Added an answer on May 16, 2026 at 6:12 am

    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.

    I want to send down a webpage from a server to WebView

    Are you talking about ‘push’ rather than ‘pull’ mechanism (like as usual with loadUrl())? That’s only available in 2.2

    (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?)

    Sample code for fetching a remote html page – afterwards you’d do the string replacement for your image urls:

    /**
     * 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();
    }
    

    Alternatively you could use

    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);
        ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.