您好,我想打开这个网址 http://3864.cloud-matic.net/从我的 android webview 中,我尝试了很多方法,但该应用程序甚至没有打开 mainActivity。我尝试过的如下。
public void onCreate(Bundle state) {
super.onCreate(state);
setContentView(R.layout.main);
WebView webView = (WebView) findViewById(R.id.webView1);
webView.setHttpAuthUsernamePassword("cloud-matic.net/", "realm", username, password);
webView.loadUrl("http://3864.cloud-matic.net/");
}
请告诉我哪里错了。 阿里
最佳答案
webview.setWebViewClient(new MyWebViewClient ());
private class MyWebViewClient extends WebViewClient {
@Override
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
handler.proceed("me@test.com", "mypassword");
}
}
这是投票最多的解决方案,我不确定在哪里设置要打开的 URL。请提出建议。
关于java - android 中的 BasicAuthentication for webview 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21185400/