我的解決我的問題。
webView.setWebViewClient(new MyWebViewClient());
private class MyWebViewClient extends WebViewClient
{
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
handler.proceed("UserName", "Password");
}
public void onPageStarted(WebView view, String url, Bitmap favicon) {
if (dialog != null) {
if (!dialog.isShowing()) {
dialog.show();
}
}
}
public void onLoadResource(WebView view, String url) {
// TODO Auto-generated method stub
super.onLoadResource(view, url);
}
public void onScaleChanged(WebView view, float oldScale, float newScale) {
// TODO Auto-generated method stub
super.onScaleChanged(view, oldScale, newScale);
}
public void onTooManyRedirects(WebView view, Message cancelMsg,
Message continueMsg) {
// TODO Auto-generated method stub
super.onTooManyRedirects(view, cancelMsg, continueMsg);
}
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
return super.shouldOverrideUrlLoading(view, url);
}
public void doUpdateVisitedHistory(WebView view, String url,
boolean isReload) {
// TODO Auto-generated method stub
super.doUpdateVisitedHistory(view, url, isReload);
}
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
// TODO Auto-generated method stub
super.onReceivedError(view, errorCode, description, failingUrl);
}
public void onPageFinished(WebView view, String url) {
if (dialog != null) {
dialog.dismiss();
}
}
}
看起來像HTTP基本認證。看看這是否有幫助:http://stackoverflow.com/questions/8935537/android-webview-with-https-connection-and-basic-auth-how-to-get-this-working –
字符串usernameRandomPassword =「httpwatch:」 + UUID.randomUUID()。toString(); \t String authorization =「Basic」+ Base64.encodeToString(usernameRandomPassword.getBytes(「UTF-8」),Base64.NO_WRAP); 我必須在哪裏設置我的登錄名和密碼? – edi233
字符串usernameRandomPassword =「user:user」; –