Setting WebView to view Desktop Site and Not Mobile Site

Solution 1:

Change the user agent of webview

 String newUA="Foo/"; // Change this to desired UA

like

 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);

Solution 2:

This method helps you to set DesktopMode on webview

public void setDesktopMode(WebView webView,boolean enabled) {
    String newUserAgent = webView.getSettings().getUserAgentString();
    if (enabled) {
        try {
            String ua = webView.getSettings().getUserAgentString();
            String androidOSString = webView.getSettings().getUserAgentString().substring(ua.indexOf("("), ua.indexOf(")") + 1);
            newUserAgent = webView.getSettings().getUserAgentString().replace(androidOSString, "(X11; Linux x86_64)");
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        newUserAgent = null;
    }

    webView.getSettings().setUserAgentString(newUserAgent);
    webView.getSettings().setUseWideViewPort(enabled);
    webView.getSettings().setLoadWithOverviewMode(enabled);
    webView.reload();
}

Call it like that

Mobile mode : setDesktopMode(webView, false);

Desktop mode : setDesktopMode(webView, true);

Solution 3:

You can use WebView to show view as Desktop Site with fit in mobile display.

        webView = (WebView)findViewById(R.id.webView1);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setUseWideViewPort(true);

        webView.getSettings().setSupportZoom(true);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setDisplayZoomControls(false);

        webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
        webView.setScrollbarFadingEnabled(false);