CookieSyncManager::createInstance() 需要在 CookieSyncManager::getInstance() 之前调用
这个错误信息非常清楚:
CookieSyncManager::createInstance() 需要之前调用 CookieSyncManager::getInstance()
但我只收到此错误,因为我遵循了官方文档:
要使用 CookieSyncManager,主机 应用程序必须调用以下内容 当应用程序启动时:
CookieSyncManager.createInstance(上下文)
要设置同步,主机 应用程序必须调用
CookieSyncManager.getInstance().startSync()
在 Activity.onResume() 中
该错误仅在应用程序尝试恢复时发生,而不是在它干净启动时发生。
因此,我可能可以通过将 CookieSyncManager.createInstance(context) 移动到 Activity.onResume() 来解决这个问题,但是...不会创建一个新的 /em> 有问题吗?
(例如,每次应用程序恢复时都会忘记以前的会话 cookie?)
This error message is pretty clear:
CookieSyncManager::createInstance()
needs to be called before
CookieSyncManager::getInstance()
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 callCookieSyncManager.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?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我按照最近的应用程序之一中的官方文档进行操作,CookieSyncMasnager 工作得很好...
我有以下内容:
我正在 createInstance() 中使用活动上下文。你没有提到你正在使用哪个上下文?
您也没有提到在 onPause() (或类似的)中执行 CookieSyncManager.getInstance().stopSync() 。因此,也许为了简历,您会调用 CookieSyncManager.getInstance().startSync() 两次而没有中间停止?
I followed the official documentation in one of recent apps and CookieSyncMasnager is working just fine...
I have the following:
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?