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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:49:29+00:00 2026-06-11T10:49:29+00:00

I’m using the loadUrl() method in an activity’s onCreate() method to load content from

  • 0

I’m using the loadUrl() method in an activity’s onCreate() method to load content from an external web server into a webview (I’m building an adroid app).

public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  super.loadUrl("http://server-name/path/to/my/server/app/");
}

On the server I check the ACCEPT HTTP header to decide which data format I will deliver to a client.

Now the problem is: the loadUrl() method seems to always send the ACCEPT header value “application/xml, …”, which will cause my server to deliver data not as nicely layouted html (this is what I want for the webview), but rather as pure xml (which is good for e.g. some web service client).

So what I want to do is to set the ACCEPT HTTP header to “text/html”, but the loadUrl() method won’t allow me to do that.

I checked out the source code for cordova/android and found, that the loadUrl() method (in CordovaWebView.java) finally calls the (android sdk) WebView’s loadUrl() method, which is overloaded to take some additional http headers. But I can’t access that loadUrl method through normal cordova use.

So I edited the CordovaWebView’s loadUrlNow() method, which calls the WebView’s loadUrl() method and hardcoded an extra header:

void loadUrlNow(String url) {
  ...
  Map<String, String> extraHeaders = new HashMap<String, String>();
  extraHeaders.put("ACCEPT", "text/html");
  super.loadUrl(url, extraHeaders);
}

then compiled it, replaced the original cordova.jar with my own and rebuild my android app. But if I now start the app and check the ACCEPT HTTP header on server side, the ACCEPT header didn’t change. It’s value is the very same than before hardcoding the extra header; it seems that I can’t change that header.

So, is there any way to set the ACCEPT http header when calling the loadUrl() method?

  • 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-11T10:49:30+00:00Added an answer on June 11, 2026 at 10:49 am

    Okay, I found the answer by myself. I found out, that I can’t override headers sent by the WebView; if I do, they get overridden by the WebView’s default values as the ADT documentation says here (see method loadUrl, parameter additionalHttpHeaders):

    http://developer.android.com/reference/android/webkit/WebView.html#loadUrl(java.lang.String, java.util.Map)

    Note that if this map contains any of the headers that are set by default by this WebView, such as those controlling caching, accept types or the User-Agent, their values may be overriden by this WebView’s defaults.

    I’m not sure, if the documentation was that clear two weeks ago (timestamp is 13 Sep 2012). As a workaround I’m trying setting a custom HTTP header like *MYAPP_ACCEPT* to “text/html” which I can evaluate on server side. To add this additional HTTP header I need to use my self-compiled cordova lib, though.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,

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.