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 9011755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:49:15+00:00 2026-06-16T02:49:15+00:00

First, I am going to say this is only an issue on Android 2

  • 0

First, I am going to say this is only an issue on Android 2 and older (4 seems to be unaffected and I didn’t test 3).

I have a WebView that loads html from a string. The HTML looks like this:

<html>  
    <head>
        <link rel='stylesheet' type='text/css' href='http://www.robotsidekick.com/test.css?rev=0' />
    </head>
    <body>
        <h1>Hello World</h1>
    </body>
</html>

You can see that css file looks like this:

body {
    font-family: "Lucida Console", "Lucida Sans Typewriter", Monaco, "Bitstream Vera Sans Mono", monospace;
}
h1 {
    border-bottom: 3px solid #ccc;
}

The WebView code looks like this:

final WebView webview = new WebView(this);
setContentView(webview);
final String result = "<html><head><link rel='stylesheet' type='text/css' href='http://www.robotsidekick.com/test.css?rev=0' /></head><body><h1>Hello World</h1></body></html>";
webview.loadData(result, "text/html", Encoding.UTF_8.toString());

What Happens

I see the html code in the WebView as if I had set the mime type to plain text.

what happens html as plain text

What I’d Expect (and what happens in Android 4.x

I see the html in the WebView

There are a few things that have to be true to show the symptoms I am seeing:

  • Android 2.x (I was using 2.3.7 and 2.2)
  • The css has to be accessed via a url href="http://www.robotsidekick.com/test.css?rev=0" as opposed to href="test.css" (however it doesn’t matter if it’s a real css file href="http://www.thisisnotarealurl.fake/test.css?rev=0 causes the same problem)
  • The css must have a get parameter ?rev=0, but it doesn’t matter what it is

Also wanted to note that the following did not make a difference:

  • Using the appropriate " instead of ' in the HTML
  • Having the link tag close itself or not
  • The contents of the css
  • Adding a doctype <!DOCTYPE html> to the HTML
  • 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-06-16T02:49:17+00:00Added an answer on June 16, 2026 at 2:49 am

    Changing the webview.loadData line to this:

    webview.loadData(URLEncoder.encode(result).replaceAll("\\+", " "), "text/html", Encoding.UTF_8.toString());
    

    Solves this problem. It seems weird to me that a relative path with an unencoded ? doesn’t cause problems, while a fake url with an unencoded ? does cause problems.

    Also find it odd that the WebView changed enough in subsequent versions of Android that we don’t have to go encoding our html anymore? That sounds fishy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, I have to say that I'm going to talk about System.ComponentModel.Component
First I would like to say that I have only worked with java for
If I have a property, say an NSArray, that's going to be initialized only
I'm going to re-ask this question in a slightly different way. Say I have
I will preface to say that this is my first question. I am currently
Let's say I have this glutIdleFunc going in the background of an OpenGL scene
First I've read loads of posts and sites that recommend going to http://silverlight.net/GetStarted/ to
First of all I should probably say that the term 'constant object' is probably
I have this problem: I have a collection of small files that are about
Lets say I have this amputated Person class: class Person { public int Age

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.