My app silently crashes (no force close popup) when i try to set a cookie on the cookiemanager.
mHttpClient.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
HttpGet http_get = new HttpGet(url);
HttpResponse response = mHttpClient.execute(http_get);
for(Cookie cookie : mHttpClient.getCookieStore().getCookies()) {
Log.d(AppPreferences.TESTTAG,"cookie = " + cookie.getName());
if(cookie.getName().equals("SACSID") || cookie.getName().equals("ACSID"))
{
response.getEntity().consumeContent();
String cookieString = cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain();
CookieManager.getInstance().setCookie(cookie.getDomain(), cookieString); //**crashes here**
return true;
}
}
Here's all i'm getting from logcat
04-19 22:51:35.277: W/dalvikvm(16704): Invalid indirect reference 0x414bb040 in decodeIndirectRef
04-19 22:51:35.277: E/dalvikvm(16704): VM aborting
04-19 22:51:35.281: A/libc(16704): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 16754 (AsyncTask #1)
Here's the tombstone log generated: http://textuploader.com/?p=6&id=gPpJ
It fails right on the CookieManager setCookie() line (i.e. I log a message before and after that line it prints the before message but not the one after)
Anyone run in to this problem?
Add CookieSyncManager.createInstance(context);
before calling CookieManager.
Try to create WebView in onCreate() method and destroy it. WebView create some "bridge" between ContentManager and WebKit. Some thing like this:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_layout);
WebView web = new WebView(this);
web.destroy();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With