BasicAuthentication android系统中的网页流量不工作 [英] BasicAuthentication in android for webview not working

查看:160
本文介绍了BasicAuthentication android系统中的网页流量不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想打开这个网址 http://3864.cloud-matic.net/ 从我的Andr​​oid的WebView,我已经尝试过很多方法,但应用程序甚至没有打开mainActivity。我曾尝试下面的。

 公共无效的onCreate(捆绑状态){
    super.onCreate(州);
    的setContentView(R.layout.main);
    web视图的WebView =(的WebView)findViewById(R.id.webView1);
    webView.setHttpAuthUsernamePassword(cloud-matic.net/,境界,用户名,密码);
    webView.loadUrl(http://3864.cloud-matic.net/);
}

请给我的想法,我错了。
阿里


解决方案

  webview.setWebViewClient(新MyWebViewClient());私有类MyWebViewClient扩展WebViewClient {
    @覆盖
    公共无效onReceivedHttpAuthRequest(的WebView视图,
            HttpAuthHandler处理器,主机字符串,字符串境界){
        handler.proceed(me@test.com,输入mypassword);
    }
}

这是大多数投票的解决方案有我不知道在哪里的URL设置为open.Please建议。

Hi I want to open this url http://3864.cloud-matic.net/ from my android webview and I have tried many ways but the app even not opens mainActivity. What I have tried is below.

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

Please give me idea where I am wrong. Ali

解决方案

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");
    }
}

This is most voted solution there I am not sure where to set the URL to open.Please suggest.

这篇关于BasicAuthentication android系统中的网页流量不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆