Desktop Mode Code

//put onCreate

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

//set Button onClick Desktop
setDesktopMode(webview1, true);

//set Button onClick Mobile
setDesktopMode(webview1, false);

Comments

  1. I tried the same in spinner menu no error but no desktop version become ture it remains bydefault false
    My webview reloads but no dekstop view

    ReplyDelete

Post a Comment

Popular posts from this blog

Swipe Refresh code