2
私はgoogle canlenderを表示するためにwebviewを使用していますが、プログラム上でGoogleアカウントを渡したいので、setHttpAuthUsernamePassword()関数は必要なものでなければなりません。コードは次のとおりです。Android webviewにgoogleアカウントを渡す方法
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/");
これを機能させることができたら、教えてください。私はたくさんの検索を試みましたが、役に立たないとは思いません。
私はGoogleのAPIのJavaクライアントを使用しても依然として認証のためのユーザー入力が必要なので、これは決してうまくいかないと思います。こちらhttp://code.google.com/apis/accounts/docs/AuthForInstalledApps.htmlをご覧ください。私を訂正してください.... – thanhbinh84