开发者

CookieSyncManager::createInstance() needs to be called before CookieSyncManager::getInstance()

This error message is pretty clear:

CookieSyncManager::createInstance() needs to be called before CookieSyncManager::getI开发者_Python百科nstance()

But I only get this error because I followed the official documentation:

To use the CookieSyncManager, the host application has to call the following when the application starts:

CookieSyncManager.createInstance(context)

To set up for sync, the host application has to call

CookieSyncManager.getInstance().startSync()

in Activity.onResume()

The error occurs only when the application attempts to resume, not when it starts cleanly.

So, I can probably fix that by moving CookieSyncManager.createInstance(context) to Activity.onResume() but... won't that create a new problem?

(for example, forgetting the previous session cookies every time the app resumes?)


I followed the official documentation in one of recent apps and CookieSyncMasnager is working just fine...

I have the following:

onCreate()
    CookieSyncManager.createInstance(this);

onResume()
    CookieSyncManager.getInstance().startSync();

onPause()
    CookieSyncManager.getInstance().stopSync();

I am using the activity context in the createInstance(). You don't mention which context you're using?

You also don't mention doing a CookieSyncManager.getInstance().stopSync() in onPause() (or similar). So perhaps for a resume you are calling CookieSyncManager.getInstance().startSync() twice without an intervening stop?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜