I have a web service. Normally I give a connection with HttpURLConnection. Here's one I need. Connect with HttpURLConnection and get session and cookie information from the HttpURLConnection and open WebView. in short Input from within the application process whether android. I want to make the rest of the operations in WebView.
Asked
Active
Viewed 2,871 times
3
-
See [Pass cookies from HttpURLConnection (java.net.CookieManager) to WebView (android.webkit.CookieManager)](http://stackoverflow.com/q/12731211/687315) – quietmint Oct 04 '12 at 16:04
1 Answers
1
Have a look at CookieSyncManager
class. With google, I found this:
CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(mWebView.getContext());
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.removeSessionCookie();
cookieManager.setCookie("http://xx.xxx.xxx.com","mid="+MySession.GetSession().sessionId+" ; Domain=.xxx.com");
cookieSyncManager.sync();
String cookie = cookieManager.getCookie("http://xx.xxx.xxx.com");
Log.d(LOGTAG, "cookie ------>"+cookie);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new TuWebViewClient());
mWebView.loadUrl("http://xx.xx.xxx.com");

Caner
- 57,267
- 35
- 174
- 180