Android如何将google帐户传递到webview
我使用webview显示google canlender,但希望通过编程方式传递google帐户,因此setHttpAuthUsernamePassword函数应该是我所需要的,但它根本不起作用。代码如下:Android如何将google帐户传递到webview,android,webview,google-calendar-api,account,Android,Webview,Google Calendar Api,Account,我使用webview显示google canlender,但希望通过编程方式传递google帐户,因此setHttpAuthUsernamePassword函数应该是我所需要的,但它根本不起作用。代码如下: WebView webview = (WebView) findViewById(R.id.webview); webview.getSettings().setJavaScriptEnabled(true); webview.setHttpAuthUsernamePassword("www
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/");
如果你有任何想法,让这个工作,请让我知道。我试着搜索了很多,但没有发现任何有用的 您正在尝试使用HTTP身份验证http://en.wikipedia.org/wiki/Basic_access_authentication 这是大多数web服务不支持的。您需要有有效的Google Cookie,只有在您使用密码手动登录时才会设置这些Cookie。您正在尝试使用HTTP身份验证http://en.wikipedia.org/wiki/Basic_access_authentication 这是大多数web服务不支持的。您需要有有效的Google Cookie,只有当您使用密码手动登录时才会设置这些Cookie。我认为这永远不会起作用,因为即使使用Google api java客户端,我们仍然需要用户输入进行授权。在这里结账。请纠正我,如果…我认为这永远不会工作,因为即使使用谷歌api java客户端,我们仍然需要用户输入进行授权。在这里结账。如果……请纠正我。。。。