-1

I created a webview into my app, and I want to put a button so the user can switch from mobile view to the desktop view and back every time he want.

I have already seen other questions about this argument but none solves my problem.

Thanks in advance

Gabriele Puia
  • 333
  • 1
  • 3
  • 10

1 Answers1

1

In order to do that, you need to change the user agent of the WebView. You could try with 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);

(Based on Setting WebView to view Desktop Site and Not Mobile Site)

I will leave you a list of other user agents you can use here: https://developers.whatismybrowser.com/useragents/explore/

emb3r
  • 51
  • 2