Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Android Webview Useragent

Is there any property or method to set the useragent for a webview, I know there is for the httpclient.

Alternatively, is there a way to take over the network side of the webview to route it through a httpclient.

I have a website that is iphone only, Want it on android, but can't change the site

— asked May 28th 2010 by Ryan Tregea
  • android
  • httpclient
  • spoof
  • useragent
  • webview
0 Comments

3 Answers

  • Accepted Answer

    You should be able to call setHeader('User-Agent','my user agent') on your XHR instance.

    — answered May 28th 2010 by Jeff Haynie
    permalink
    3 Comments
    • I'm not quite following, is there a way to access the httpclient instance for the webview?

      — commented May 28th 2010 by Ryan Tregea
    • Yeah i've just double checked, the HTTPclient instance is what you meant, Yeah that's fine i can set it there, however i want the user to be able to access back and forward to the server with the faked user agent.

      So i need to set the header for a webview. Is there some undocumented methods before each page request that i could redirect with httpclient

      — commented May 28th 2010 by Ryan Tregea
    • OK - I see, you're talking about the webview and not an XHR client request. We'll have to look into the ability to change the UA for the internal WebView. Looks like it's possible looking at Javadocs for Android.

      I have opened a ticket for this.

      — commented May 29th 2010 by Jeff Haynie
  • I made the modules to set custom UserAgent string to your webview. Please check and use it if it helps you.

    https://github.com/harukazepc/TiWebViewUserAgent

    and, you may use Ti.UI.WebView#setUserAgent() at Titanium 1.8.

    — answered February 19th 2012 by tomoya narita
    permalink
    1 Comment
    • the userAgent has been included in Titanium 1.8 indeed.

      — commented July 10th 2012 by Alberto Marcone
  • Yeah i've just double checked, the HTTPclient instance is what you meant, Yeah that's fine i can set it there, however i want the user to be able to access back and forward to the server with the faked user agent.

    So i need to set the header for a webview. Is there some undocumented methods before each page request that i could redirect with httpclient

    — answered May 29th 2010 by Ryan Tregea
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.