Skip to content Skip to sidebar Skip to footer

Nullpointerexception In Cookiesyncmanager.createinstance In Asynctask

I have a class that extends from AysncTask. Inside the doInBackground method I want to update the cookies, so I have: CookieSyncManager.createInstance(context); // <<<

Solution 1:

I call it in Application's onCreate() passing the application as context

Solution 2:

I've never used CookieSyncManager, but from what I can see in the docs may be you should not use it within a Thread because its already creating one:

A separate thread saves the cookies between, driven by a timer.

  • You should call createInstance when the application starts, usually in onCreate()
  • getInstance().startSync() In Activity.onResume()
  • And getInstance().stopSync() in Activity.onPause()

Here you have an example

Hope this help.

Post a Comment for "Nullpointerexception In Cookiesyncmanager.createinstance In Asynctask"