我正在使用 webview 来显示 google canlender,但想以编程方式传递 google 帐户,所以 setHttpAuthUsernamePassword() 函数应该是我需要的,但它根本不起作用。这是代码:
WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.setHttpAuthUsernamePassword("www.google.com", "", "email", "password");
webview.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedHttpAuthRequest (WebView view, HttpAuthHandler handler, String host,String realm){
handler.proceed("email","password");
}
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
}
});
webview.loadUrl("http://www.google.com/calendar/");
如果您有任何想法来实现这一点,请告诉我。我试图搜索很多,但没有看到任何有用的。