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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:25:36+00:00 2026-06-14T07:25:36+00:00

Been trying to change the User-Agent string in the HTTP request of an Android

  • 0

Been trying to change the User-Agent string in the HTTP request of an Android app. I have tested this together with wireshark and the emulator, and have seen that although I set the useragent string in the webview, the associated loadUrl request does not use this user-agent string. Instead I see the Dalvik useragent string in the wireshark capture.
Here is the code abstract. Any ideas? Or does the emulator not support this?

@Override
public void run() {
    assert(context != null);

    ...
    ...
    webView = new WebView(context);
    ...
    String defaultUserAgent = "betaUAteststring";


    // Clear per-application caches etc
    webView.clearCache(true);
    webView.clearHistory();
    webView.getSettings().setAppCacheEnabled(false);
    webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    webView.getSettings().setJavaScriptEnabled(true);


    webView.setWebViewClient(new WebViewClient() {
        @Override  
        public void onPageFinished(WebView view, String url) {
        ....
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
        ..
        }

        @Override
        public void onLoadResource(WebView view, String url) {
        ...
        }
    });


    // Start loading


    webView.getSettings().setUserAgentString(defaultUserAgent);
    String setUA = webView.getSettings().getUserAgentString();
    //--> logging here shows the correct user agent, so the webview does accept the value
    // However the following statement does not result in an http request with the webviews user agent
    webView.loadUrl(url);

    //Alternative doesn't help either (and shouldn't according to javadoc)

    //Map<String,String> headerMap = new HashMap<String,String>();
    //headerMap.put("User-Agent","uaTestInAMap");        
    //webView.loadUrl(url, headerMap);
}
  • 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-14T07:25:37+00:00Added an answer on June 14, 2026 at 7:25 am

    Answering my own question. It appears that the emulator for whatever reason is not taking the user agent string from the webview. I have not found out the reason for this however.
    The code works fine on a real device.

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

Sidebar

Related Questions

I have been trying to change the cursor style to look like a pointer
Been trying to find this online for a while now. I have a SDL_Surface
I have been trying to user sharepoint designer to retrieve the user's full name
I have been trying to do a search of the user directory and subdirectories
Ok so I have been trying to fix this for days, and I'm not
I have been trying to figure out this problem for a while now and
I have been trying to register 3 hotkeys. I followed this example (or this
I have been trying to create a simple application that will let the user
I've been trying to google this but have been unable to find a solution
I have been trying to make a clock that the user can set. I

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.