2

私は 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/");

これを機能させるためのアイデアがあれば、お知らせください。私はたくさん検索しようとしましたが、有用なものは見当たりません。

4

1 に答える 1

0

ほとんどの Web サービスでサポートされていない HTTP 認証 (http://en.wikipedia.org/wiki/Basic_access_authentication) を使用しようとしています。パスワードを使用して手動でサインインした場合にのみ設定される、有効な Google Cookie が必要です。

于 2012-03-28T13:56:07.650 に答える