android webview get initial cooke
<p>i need to login in an https page with used credentials.But my problem is that i am not able to get the cookie from the initial request.i am using an webview.Bascically i first need to get the cookie from an http request and then sent an https request with that cookie and user credentials.</p>

<p>Following is my OnCreate() method</p>

<pre><code> CookieSyncManager.createInstance(this); 
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
if (cookie != null) {
    cookieManager.removeSessionCookie();
    String cookieString = cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain() ;
    cookieManager.setCookie(cookie.getDomain(), cookieString);
    CookieSyncManager.getInstance().sync();
}  

WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);

webView.loadUrl("www.xyz.com");

webView.setWebViewClient(new MyWebViewClient());
</code></pre>

<p>and MyWebViewClient</p>

<pre><code>private class MyWebViewClient extends WebViewClient{

    @Override
       public boolean shouldOverrideUrlLoading(WebView view, String url) {
           view.loadUrl(url);
           return true;
       }   
   } 
    public void onPageFinished(WebView view, String url) {
        CookieSyncManager.getInstance().sync();

    };

       return null;
    }
</code></pre>

<p>i am calling https link by this way </p>

<pre><code>       HttpClient hc;
    HttpGet get = null;
    HttpResponse httpResponseData = null;
    HttpParams httpParameters = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParameters, 5000);
    HttpConnectionParams.setSoTimeout(httpParameters, 5000);

    final List&lt;BasicNameValuePair&gt; nvps = new ArrayList&lt;BasicNameValuePair&gt;();
    nvps.add(new BasicNameValuePair("id", id));
    nvps.add(new BasicNameValuePair("pass", pass));
    hc = new DefaultHttpClient(httpParameters);
    String URL = "https://xyz.com";
    final UrlEncodedFormEntity p_entity = new UrlEncodedFormEntity(nvps, HTTP.UTF_8);
    URL += p_entity;
    get = new HttpGet(URL);
    httpResponseData = hc.execute(get);
    if(httpResponseData != null){

    }
</code></pre>

<p>How should i first get cookie and attach it with this request.</p>

<p>Thanks</p>
