BasicAuthentication in android for webview not working

Tags: , , ,

Hi I want to open this url 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) {
    WebView webView = (WebView) findViewById(;
    webView.setHttpAuthUsernamePassword("",     "realm", username, password);

Please give me idea where I am wrong. Ali


webview.setWebViewClient(new MyWebViewClient ());

private class MyWebViewClient extends WebViewClient {
    public void onReceivedHttpAuthRequest(WebView view,
            HttpAuthHandler handler, String host, String realm) {
        handler.proceed("", "mypassword");

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

Source: stackoverflow