【问题标题】:Android how to pass google account to webviewAndroid如何将谷歌帐户传递给webview
【发布时间】:2011-01-26 08:12:52
【问题描述】:

我正在使用 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/");

如果您有任何想法来实现这一点,请告诉我。我试图搜索很多,但没有看到任何有用的。

【问题讨论】:

标签: android webview google-calendar-api account


【解决方案1】:

您正在尝试使用大多数 Web 服务不支持的 HTTP 身份验证 (http://en.wikipedia.org/wiki/Basic_access_authentication)。您需要拥有有效的 Google cookie,这些 cookie 仅在您使用密码手动登录时设置。

【讨论】:

    猜你喜欢
    • 2018-06-11
    • 1970-01-01
    • 2012-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-08
    • 1970-01-01
    相关资源
    最近更新 更多