【问题标题】:androidx proxyconfig how to set user password authenticationandroidx proxyconfig如何设置用户密码认证
【发布时间】:2021-08-12 11:39:46
【问题描述】:

如何添加用户密码?我的代理使用用户密码进行身份验证 代码 androidx.webkit:1.4.0

//my code need to add user password
public void setProxy(){
 if(WebViewFeature.isFeatureSupported(WebViewFeature.PROXY_OVERRIDE)) {
            ProxyConfig proxyConfig = new ProxyConfig.Builder()
                . addProxyRule("123.123.123.123:8080")
                . addDirect().build();
            ProxyController.getInstance().setProxyOverride(proxyConfig, new Executor() {
                    @Override
                    public void execute(Runnable command) {
                        //do nothing
                    }
                }, new Runnable() {
                    @Override
                    public void run() {
                        Log.w(TAG, "WebView");
            
                    }
                });
}
}     

【问题讨论】:

    标签: android proxy


    【解决方案1】:

    很容易为http https代理webview设置用户密码代理。 字符串用户 = “xxxx” 字符串密码 = "xxxx" 但是 socks 代理不能这样工作。请帮助任何人

    myWebView.setWebViewClient(new WebViewClient(){
                   @Override
                    public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
                       
                        handler.proceed(user, password);
                    }
               });  
    

    完成!!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多