【发布时间】:2013-12-12 20:58:14
【问题描述】:
Even though the android process is killed,the activity stack is maintained.
For Example: 我在我的应用程序中跨越了四个屏幕,cookie 存储在CookieManager 中。现在我按下主页按钮,android 终止进程。由于进程被终止,android CookieManager 实例也被终止(所有存储的 cookie 都被删除)。
当我恢复到应用程序时,它从我离开的活动开始,但现在不再有 cookie。
Possible solutions: (Considering Html(WebView) + android is used in app)
-
需要在持久化存储中维护 cookie。(不依赖于 Android CookieManager)。
Challenges:webview 使用 cookieManager 来存储它的 cookie。我们需要将我们的 cookie 与 webView cookie(存储在 cookie 管理器中的 cookie)同步。
何时删除所有持久化 cookie。我们是否有任何针对应用程序退出的 android 特定回调?
-
如果进程被终止,则从开始(从建立 cookie 的位置)重新启动应用程序。
Possibile Soln:Android Application 类的 oncreate 会在新进程启动时被调用 created.那个时间点,我们就可以从启动应用启动了。有没有更好的解决方案?
如果我们要实现一个自定义类来维护 cookie,那么使用 android CookieManager 有什么意义?
【问题讨论】:
-
按主页按钮通常不会杀死进程!
-
通常android不会在我们按下home键的时候杀死进程。但是当android需要杀死进程时,与前台进程相比,android给后台进程的优先级较低。这就是我的意思。跨度>
标签: android memory-management process android-cookiemanager