title: Android Hybrid App + Volley, Cookies and WebView
body: <p>I have researched for > 15 hours about this problem:
  I am building a Hybrid App , I login with the Volley Framework (native View),
  as soon as I login I fetch the response Header,extract the Cookie and save it into my sharedprefs. After successful login I have a native mainscreen that contains links to several Webviews, 
  how do I pass the Cookie I received from the login into the Webview?
  90% of the Answers on the Internet use CookieSyncManager, which is deprecated.
  I tried the java.net.CookieManager also, nothing of it works.</p>
  
  <p>Here's my Code</p>
  
  <pre><code>  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      mWebView = new WebView(this);
  
      setContentView(mWebView);
  
      cookies = pref.getString(Const.COOKIE_KEY,"null");
      userID = pref.getString(Const.USER_ID_KEY,"null");
      mUrl = Const.PERFORMANCE_WEBVIEW_LINK + Const.USER_ID;
      String cookieText = Const.COOKIE_KEY + "=" + cookies;
  
      //Approach A Environment for the Cookies
      //Does not work
      cookieSync = CookieSyncManager.createInstance(this);
      cookieManager = CookieManager.getInstance();
      cookieManager.removeSessionCookie();
      cookieManager.setCookie(mUrl, cookieText);
      cookieSync.sync();
  
      SystemClock.sleep(10000);
  
      /*APPROACH B, sending the Cookies with header
        ##Did not Work##
      final Map&lt;String, String&gt; headers = new HashMap&lt;&gt;();
  
      Log.d("cookie", cookieText);
      headers.put("Cookie",cookieText);
      */
  
      if(cookies.equals("null") || userID.equals("null")) {
          Toast.makeText(PerformanceWebview.this, "Error", Toast.LENGTH_SHORT).show();
          //Logging Out
          Intent intent = new Intent(this, LoginActivity.class);
          startActivity(intent);
      }
      else {
          //mWebView.loadUrl(mUrl,headers);
          mWebView.loadUrl(mUrl);
          Toast.makeText(PerformanceWebview.this,cookieText, Toast.LENGTH_SHORT).show();
          Log.d("URL", "URL: " + mUrl);
      }
  
  
  }
  </code></pre>
  
  <p>I also tried passing a WebClient to the WebView and overrode it's shouldOverrideURl method and passed the headers into it.
  Another approach I did was using WebSettings and passing a ChromeClient..</p>
  
  <p>None of the Answers here seem to work</p>