Using WebView setHttpAuthUsernamePassword?

前端 未结 8 631
死守一世寂寞
死守一世寂寞 2020-11-30 05:45

I\'m trying to do basic authentication to view a protected url. I want to access the protected url which looks like this:

http://api.test.com/userinfo/vid?=1         


        
8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 06:24

    Another option is to use a WebViewClient;

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

提交回复
热议问题