我已经构建了一个应用程序来加载WebView
并传递cookies
。我的应用程序在KitKat版本的android中运行良好。
但WebView
未加载jelly bean
或较低版本。这意味着我的WebView
未在cookies
或较低版本中传递jelly bean
。
这可能不会在较低的 Android版本中加载WebView
吗?如果可能的话,该怎么做?
请指导我并帮助我。
听我在我的活动中存储cookie。
CookieSyncManager.getInstance().startSync();
CookieSyncManager syncManager = CookieSyncManager.createInstance(MainActivity2.this);
syncManager.sync();
CookieManager manager = new CookieManager();
manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(manager);
CookieStore cookieJar = manager.getCookieStore();
cookies1 = cookieJar.getCookies();
editor.putString("coockies", String.valueOf(cookies1));
//List<Cookie> cookies = httpclient.getCookieStore().getCookies();
for (int i = 0; i < cookies1.size(); i++) {
cookie = cookies1.get(i);
Log.d("cookie", String.valueOf(cookie));
}
听到我在webview中传递cookie
enter code here wv = new WebView(this);
wv=(WebView)findViewById(R.id.webView);
HttpCookie sessionCookie = myactivity.cookie;
Log.d("Session Coockies",String.valueOf(sessionCookie));
CookieSyncManager.createInstance(this);
CookieManager cookieManager = CookieManager.getInstance();
if (sessionCookie != null) {
cookieManager.removeSessionCookie();
String cookieString = sessionCookie.getName() + "=" + sessionCookie.getValue() + "; domain=" + sessionCookie.getDomain();
Log.d("cookistring",cookieString);
cookieManager.setCookie("", cookieString);
CookieSyncManager.getInstance().sync();
// String cookieString = sessionCookie.getName() + "=" + sessionCookie.getValue() + ";domain=";
}
wv.getSettings().setLoadsImagesAutomatically(true);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setDomStorageEnabled(true);
wv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
//setContentView(myWebView);
String url="my url";
Log.d("url",url);
wv.loadUrl(url);