I have a WebView project, I turn to a site that is adapted for mobile devices, my task is to log in as if from a computer. I substitute User-Agent - nothing comes out. The site still throws on the mobile version. Apparently the site looks at the resolution of the screen / browser and throws it on the mobile version. How can I cheat him? How to prevent my WebView (or some headers) from sending information about screen sizes or replacing them?
- How do you substitute the User-Agent? - TimurVI
- Like this: mWebView.getSettings (). SetUserAgentString ("Mozilla / 5.0 (Macintosh; Intel - Vertov
- I had such trouble that the change of agent did not change anything. And it was something in the cache, then in the cookies, I don’t remember - try to clean them before changing the agent. - woesss
|
2 answers
Try this
String newUA= "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0"; mWebView.getSettings().setUserAgentString(newUA); - It doesn't work: (The result is the same. There, in media requests, apparently already redirects to a mobile layout, how to "tell" the site that I have more device resolution, so that he thinks I am from a computer?) - Vertov
- I looked) I tried it - it does not work) they write everything about the user agent, but it seems to me that the layout with media queries simply determines that the screen width is small and it cannot be a computer, therefore it displays the mobile version. How to let the site know that I have a big permission? - Vertov
|
Try this:
public void setDesktopMode(WebSettings webSettings, final boolean enabled) { final String newUserAgent; if (enabled) { newUserAgent = webSettings.getUserAgentString().replace("Mobile", "eliboM").replace("Android", "diordnA"); } else { newUserAgent = webSettings.getUserAgentString().replace("eliboM", "Mobile").replace("diordnA", "Android"); } webSettings.setUserAgentString(newUserAgent); webSettings.setUseWideViewPort(enabled); webSettings.setLoadWithOverviewMode(enabled); webSettings.setSupportZoom(enabled); webSettings.setBuiltInZoomControls(enabled); } - No: (nothing comes out anyway, the mobile version is shown - Vertov
- Javascript enabled? - Barmaley
- Yes, of course) the problem is the width of the screen, css media queries understand that my screen width is small and displays a mobile version. How can I make the site understand that I have a big permission? - Vertov
|