Hello, I'm trying to make the web.whatsapp website open in webview but to no avail.
It displays the following message:
Mycodeis:
publicWebViewnav;publicButtonentrar;publicvoidsetDesktopMode(WebViewwebView,booleanenabled){StringnewUserAgent=webView.getSettings().getUserAgentString();if(enabled){try{Stringua=webView.getSettings().getUserAgentString();StringandroidOSString=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);
}
});
}
}