2
我正在使用webview來顯示谷歌canlender但希望通過谷歌帳戶programmatic-ally,所以setHttpAuthUsernamePassword()函數應該是我所需要的,但它根本不起作用。這裏是代碼:Android如何將谷歌帳戶傳遞給webview
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/");
如果您有任何想法使這工作,請讓我知道。我試圖搜索很多,但沒有看到任何有用的東西。
我認爲這將永遠不會工作,因爲即使使用谷歌api Java客戶端,我們仍然需要用戶輸入授權。點擊此處http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html。請糾正我,如果.... – thanhbinh84 2011-01-27 08:18:54