我正在制作一个在webview上加载电报桌面网页(web.telegram.org)的应用程序。
我想登录一次。这是我的java代码(适用于其他网站但不适用于电报桌面。
final WebView web = (WebView)popupView.findViewById(R.id.webView1);
WebSettings settings = web.getSettings();
settings.setDefaultTextEncodingName("utf-8");
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setLoadWithOverviewMode(true);
web.getSettings().setUseWideViewPort(true);
web.getSettings().setBuiltInZoomControls(true);
web.loadUrl("http://google.com/");
web.getSettings().getJavaScriptCanOpenWindowsAutomatically();
web.getSettings().setAllowFileAccessFromFileURLs(true);
web.getSettings().setAllowUniversalAccessFromFileURLs(true);
web.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
web.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
web.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
//Users will be notified in case there's an error (i.e. no internet connection)
Toast.makeText(getApplicationContext(), "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
public void onPageFinished(WebView view, String url) {
CookieSyncManager.getInstance().sync();
}
});
web.getSettings().setSavePassword(true);
web.getSettings().setSaveFormData(true);
我该怎么办?请帮帮我!