Olá, estou tentando fazer com que o site do web.whatsapp abra no webview mas sem sucesso.
Ele apresenta a seguinte mensagem:
O meu código:
public WebView nav;
public Button entrar;
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();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
nav = (WebView)findViewById(R.id.vNav);
entrar = (Button)findViewById(R.id.bEntrar);
nav.setWebViewClient(new WebViewClient());
nav.getSettings().setJavaScriptEnabled(true);
entrar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
nav.loadUrl("https://web.whatsapp.com/");
setDesktopMode(nav, true);
String userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/13";
nav.getSettings().setUserAgentString(userAgent);
nav.getSettings().setJavaScriptEnabled(true);
nav.getSettings().setLoadWithOverviewMode(true);
nav.getSettings().setUseWideViewPort(true);
nav.getSettings().setSupportZoom(true);
nav.getSettings().setBuiltInZoomControls(true);
nav.getSettings().setDisplayZoomControls(false);
nav.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
nav.setScrollbarFadingEnabled(false);
}
});
}