- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
只要我停留在同一个 fragment 中,缓存就可以正常工作。但是,一旦我将应用程序切换到后台,然后在 onResume() 上重新加载数据,缓存就不再有效,并且建立了网络连接。
这是我的代码:
protected void loadData(final OnDataLoadListener onDataLoadListener) {
final ReverseStringRequestListener listener = new ReverseStringRequestListener(onDataLoadListener);
final String cacheKey = "cacheKey234234";
final ConfigFeedRequest request = new ConfigFeedRequest("http://app.tty-eli.com/index.php?id=3");
getSpiceManager().getFromCacheAndLoadFromNetworkIfExpired(request, cacheKey, DurationInMillis.ONE_SECOND * 50, listener);
}
知道为什么会发生这种情况吗?我正在这样的 fragment 的类头中创建 SpiceManager:
private SpiceManager spiceManager = new SpiceManager(InMemorySpiceService.class);
这是日志:
10-07 16:07:06.595 5618-5618/at.tty_eli.app D//SpiceManager.java:212﹕ 16:07:06.606 main SpiceManager started.
10-07 16:07:06.605 5618-5618/at.tty_eli.app V/AppointmentFragment_﹕ onResume
10-07 16:07:06.605 5618-5618/at.tty_eli.app D//SpiceManager.java:489﹕ 16:07:06.619 main adding request to request queue
10-07 16:07:06.605 5618-5618/at.tty_eli.app D/AbsListView﹕ onVisibilityChanged() is called, visibility : 0
10-07 16:07:06.605 5618-5618/at.tty_eli.app D/AbsListView﹕ unregisterIRListener() is called
10-07 16:07:06.615 5618-6034/at.tty_eli.app V//SpiceManager.java:1191﹕ 16:07:06.623 SpiceManagerThread 2 Binding to service.
10-07 16:07:06.625 5618-5618/at.tty_eli.app D//SpiceService.java:134﹕ 16:07:06.631 main SpiceService instance created.
10-07 16:07:06.625 5618-5618/at.tty_eli.app D/AbsListView﹕ unregisterIRListener() is called
10-07 16:07:06.625 5618-6034/at.tty_eli.app V//SpiceManager.java:1197﹕ 16:07:06.633 SpiceManagerThread 2 Binding to service succeeded.
10-07 16:07:06.625 5618-6034/at.tty_eli.app D//SpiceManager.java:1245﹕ 16:07:06.637 SpiceManagerThread 2 Waiting for service to be bound.
10-07 16:07:06.645 5618-5618/at.tty_eli.app V//SpiceService.java:506﹕ 16:07:06.656 main Pending requests : 0
10-07 16:07:06.645 5618-5618/at.tty_eli.app V//SpiceService.java:508﹕ 16:07:06.658 main Stop foreground
10-07 16:07:06.655 5618-5618/at.tty_eli.app D//SpiceServiceListenerNotifier.java:33﹕ 16:07:06.662 main Message Queue starting
10-07 16:07:06.655 5618-5618/at.tty_eli.app D//SpiceManager.java:1088﹕ 16:07:06.664 main Bound to service : InMemorySpiceService
10-07 16:07:06.665 5618-6034/at.tty_eli.app D//SpiceManager.java:1252﹕ 16:07:06.673 SpiceManagerThread 2 Bound ok.
10-07 16:07:06.665 5618-6034/at.tty_eli.app D//SpiceManager.java:286﹕ 16:07:06.678 SpiceManagerThread 2 Sending request to service : CachedSpiceRequest
10-07 16:07:06.675 5618-6034/at.tty_eli.app D//RequestProcessor.java:63﹕ 16:07:06.683 SpiceManagerThread 2 Adding request to queue 1121951496: CachedSpiceRequest [requestCacheKey=cacheKey234234, cacheDuration=50000, spiceRequest=at.tty_eli.app.network.ConfigFeedRequest@42c24c50] size is 0
10-07 16:07:06.675 5618-6034/at.tty_eli.app D//RequestProcessor.java:85﹕ 16:07:06.689 SpiceManagerThread 2 Adding entry for type class at.tty_eli.app.network.ConfigFeedResponse and cacheKey cacheKey234234.
10-07 16:07:06.685 5618-6034/at.tty_eli.app D//RequestProgressManager.java:61﹕ 16:07:06.692 SpiceManagerThread 2 Request was added to queue.
10-07 16:07:06.685 5618-6034/at.tty_eli.app D//SpiceServiceListenerNotifier.java:146﹕ 16:07:06.695 SpiceManagerThread 2 Message queue is Handler (android.os.Handler) {42dfa580}
10-07 16:07:06.685 5618-5618/at.tty_eli.app D//SpiceServiceListenerNotifier.java:175﹕ 16:07:06.698 main Processing request added: CachedSpiceRequest [requestCacheKey=cacheKey234234, cacheDuration=50000, spiceRequest=at.tty_eli.app.network.ConfigFeedRequest@42c24c50]
10-07 16:07:06.695 5618-6034/at.tty_eli.app D//RequestProgressManager.java:82﹕ 16:07:06.703 SpiceManagerThread 2 Sending progress PENDING
10-07 16:07:06.695 5618-6034/at.tty_eli.app D//SpiceServiceListenerNotifier.java:146﹕ 16:07:06.708 SpiceManagerThread 2 Message queue is Handler (android.os.Handler) {42dfa580}
10-07 16:07:06.705 5618-5618/at.tty_eli.app V//DefaultRequestListenerNotifier.java:131﹕ 16:07:06.710 main Notifying 1 listeners of progress com.octo.android.robospice.request.listener.RequestProgress@42c24c88
10-07 16:07:06.705 5618-6038/at.tty_eli.app D//DefaultRequestRunner.java:83﹕ 16:07:06.714 Thread-6031 Processing request : CachedSpiceRequest [requestCacheKey=cacheKey234234, cacheDuration=50000, spiceRequest=at.tty_eli.app.network.ConfigFeedRequest@42c24c50]
10-07 16:07:06.705 5618-6034/at.tty_eli.app V//SpiceService.java:506﹕ 16:07:06.713 SpiceManagerThread 2 Pending requests : 1
10-07 16:07:06.705 5618-6038/at.tty_eli.app D//DefaultRequestRunner.java:97﹕ 16:07:06.718 Thread-6031 Loading request from cache : CachedSpiceRequest [requestCacheKey=cacheKey234234, cacheDuration=50000, spiceRequest=at.tty_eli.app.network.ConfigFeedRequest@42c24c50]
10-07 16:07:06.715 5618-6038/at.tty_eli.app D//RequestProgressManager.java:82﹕ 16:07:06.720 Thread-6031 Sending progress READING_FROM_CACHE
10-07 16:07:06.715 5618-6038/at.tty_eli.app D//SpiceServiceListenerNotifier.java:146﹕ 16:07:06.727 Thread-6031 Message queue is Handler (android.os.Handler) {42dfa580}
10-07 16:07:06.715 5618-5618/at.tty_eli.app V//DefaultRequestListenerNotifier.java:131﹕ 16:07:06.729 main Notifying 1 listeners of progress com.octo.android.robospice.request.listener.RequestProgress@42b0d130
10-07 16:07:06.725 5618-6034/at.tty_eli.app V//SpiceService.java:508﹕ 16:07:06.716 SpiceManagerThread 2 Stop foreground
10-07 16:07:06.725 5618-6038/at.tty_eli.app D//LruCacheObjectPersister.java:47﹕ 16:07:06.732 Thread-6031 Miss from lru cache for cacheKey234234
10-07 16:07:06.725 5618-6038/at.tty_eli.app D//LruCacheObjectPersister.java:47﹕ 16:07:06.737 Thread-6031 Miss from lru cache for cacheKey234234
10-07 16:07:06.735 5618-6038/at.tty_eli.app D//DefaultRequestRunner.java:129﹕ 16:07:06.741 Thread-6031 Cache content not available or expired or disabled
10-07 16:07:06.745 5618-6038/at.tty_eli.app D//DefaultRequestRunner.java:148﹕ 16:07:06.751 Thread-6031 Calling netwok request.
10-07 16:07:06.745 5618-6038/at.tty_eli.app D//RequestProgressManager.java:82﹕ 16:07:06.755 Thread-6031 Sending progress LOADING_FROM_NETWORK
10-07 16:07:06.755 5618-6038/at.tty_eli.app D//SpiceServiceListenerNotifier.java:146﹕ 16:07:06.760 Thread-6031 Message queue is Handler (android.os.Handler) {42dfa580}
10-07 16:07:06.755 5618-5618/at.tty_eli.app V//DefaultRequestListenerNotifier.java:131﹕ 16:07:06.763 main Notifying 1 listeners of progress com.octo.android.robospice.request.listener.RequestProgress@42c11c38
10-07 16:07:10.435 5618-6038/at.tty_eli.app D//DefaultRequestRunner.java:151﹕ 16:07:10.442 Thread-6031 Network request call ended.
10-07 16:07:10.435 5618-6038/at.tty_eli.app D//DefaultRequestRunner.java:171﹕ 16:07:10.447 Thread-6031 Start caching content...
10-07 16:07:10.445 5618-6038/at.tty_eli.app D//RequestProgressManager.java:82﹕ 16:07:10.453 Thread-6031 Sending progress WRITING_TO_CACHE
10-07 16:07:10.455 5618-6038/at.tty_eli.app D//SpiceServiceListenerNotifier.java:146﹕ 16:07:10.459 Thread-6031 Message queue is Handler (android.os.Handler) {42dfa580}
10-07 16:07:10.455 5618-5618/at.tty_eli.app V//DefaultRequestListenerNotifier.java:131﹕ 16:07:10.462 main Notifying 1 listeners of progress com.octo.android.robospice.request.listener.RequestProgress@42a3aa28
10-07 16:07:10.455 5618-6038/at.tty_eli.app D//LruCacheObjectPersister.java:74﹕ 16:07:10.467 Thread-6031 Put in lru cache for cacheKey234234
10-07 16:07:10.465 5618-6038/at.tty_eli.app D//RequestProgressManager.java:82﹕ 16:07:10.473 Thread-6031 Sending progress COMPLETE
10-07 16:07:10.475 5618-6038/at.tty_eli.app D//SpiceServiceListenerNotifier.java:146﹕ 16:07:10.480 Thread-6031 Message queue is Handler (android.os.Handler) {42dfa580}
10-07 16:07:10.475 5618-5618/at.tty_eli.app V//DefaultRequestListenerNotifier.java:131﹕ 16:07:10.483 main Notifying 1 listeners of progress com.octo.android.robospice.request.listener.RequestProgress@42a977a0
10-07 16:07:10.475 5618-6038/at.tty_eli.app D//SpiceServiceListenerNotifier.java:146﹕ 16:07:10.488 Thread-6031 Message queue is Handler (android.os.Handler) {42dfa580}
10-07 16:07:10.485 5618-5618/at.tty_eli.app V//DefaultRequestListenerNotifier.java:166﹕ 16:07:10.491 main Notifying 1 listeners of request success
10-07 16:07:10.485 5618-5618/at.tty_eli.app V//DefaultRequestListenerNotifier.java:172﹕ 16:07:10.494 main Notifying ReverseStringRequestListener
10-07 16:07:10.485 5618-5618/at.tty_eli.app V/AppointmentFragment_﹕ onDataReady
10-07 16:07:10.495 5618-6038/at.tty_eli.app V//RequestProgressManager.java:161﹕ 16:07:10.503 Thread-6031 Removing CachedSpiceRequest [requestCacheKey=cacheKey234234, cacheDuration=50000, spiceRequest=at.tty_eli.app.network.ConfigFeedRequest@42c24c50] size is 1
10-07 16:07:10.505 5618-6038/at.tty_eli.app D//RequestProgressManager.java:91﹕ 16:07:10.508 Thread-6031 Sending all request complete.
10-07 16:07:10.515 5618-6038/at.tty_eli.app V//SpiceService.java:495﹕ 16:07:10.520 Thread-6031 Pending requests : 0
10-07 16:07:10.515 5618-6038/at.tty_eli.app D//SpiceServiceListenerNotifier.java:146﹕ 16:07:10.524 Thread-6031 Message queue is Handler (android.os.Handler) {42dfa580}
10-07 16:07:10.545 5618-5618/at.tty_eli.app D/AbsListView﹕ unregisterIRListener() is called
10-07 16:07:10.565 5618-6038/at.tty_eli.app D//DefaultRequestRunner.java:295﹕ 16:07:10.569 Thread-6031 It tooks 3828 ms to process request CachedSpiceRequest [requestCacheKey=cacheKey234234, cacheDuration=50000, spiceRequest=at.tty_eli.app.network.ConfigFeedRequest@42c24c50].
终端
最佳答案
发生这种情况的原因是,一旦没有 Activity 绑定(bind)到该服务,该服务就会停止。为了避免丢失所有缓存数据,请将其写入磁盘或数据库。
关于android - RoboSpice:应用程序恢复后无法从缓存加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26244657/
我通过 spring ioc 编写了一些 Rest 应用程序。但我无法解决这个问题。这是我的异常(exception): org.springframework.beans.factory.BeanC
我对 TestNG、Spring 框架等完全陌生,我正在尝试使用注释 @Value通过 @Configuration 访问配置文件注释。 我在这里想要实现的目标是让控制台从配置文件中写出“hi”,通过
为此工作了几个小时。我完全被难住了。 这是 CS113 的实验室。 如果用户在程序(二进制计算器)结束时选择继续,我们需要使用 goto 语句来到达程序的顶部。 但是,我们还需要释放所有分配的内存。
我正在尝试使用 ffmpeg 库构建一个小的 C 程序。但是我什至无法使用 avformat_open_input() 打开音频文件设置检查错误代码的函数后,我得到以下输出: Error code:
使用 Spring Initializer 创建一个简单的 Spring boot。我只在可用选项下选择 DevTools。 创建项目后,无需对其进行任何更改,即可正常运行程序。 现在,当我尝试在项目
所以我只是在 Mac OS X 中通过 brew 安装了 qt。但是它无法链接它。当我尝试运行 brew link qt 或 brew link --overwrite qt 我得到以下信息: ton
我在提交和 pull 时遇到了问题:在提交的 IDE 中,我看到: warning not all local changes may be shown due to an error: unable
我跑 man gcc | grep "-L" 我明白了 Usage: grep [OPTION]... PATTERN [FILE]... Try `grep --help' for more inf
我有一段代码,旨在接收任何 URL 并将其从网络上撕下来。到目前为止,它运行良好,直到有人给了它这个 URL: http://www.aspensurgical.com/static/images/a
在过去的 5 个小时里,我一直在尝试在我的服务器上设置 WireGuard,但在完成所有设置后,我无法 ping IP 或解析域。 下面是服务器配置 [Interface] Address = 10.
我正在尝试在 GitLab 中 fork 我的一个私有(private)项目,但是当我按下 fork 按钮时,我会收到以下信息: No available namespaces to fork the
我这里遇到了一些问题。我是 node.js 和 Rest API 的新手,但我正在尝试自学。我制作了 REST API,使用 MongoDB 与我的数据库进行通信,我使用 Postman 来测试我的路
下面的代码在控制台中给出以下消息: Uncaught DOMException: Failed to execute 'appendChild' on 'Node': The new child el
我正在尝试调用一个新端点来显示数据,我意识到在上一组有效的数据中,它在数据周围用一对额外的“[]”括号进行控制台,我认为这就是问题是,而新端点不会以我使用数据的方式产生它! 这是 NgFor 失败的原
我正在尝试将我的 Symfony2 应用程序部署到我的 Azure Web 应用程序,但遇到了一些麻烦。 推送到远程时,我在终端中收到以下消息 remote: Updating branch 'mas
Minikube已启动并正在运行,没有任何错误,但是我无法 curl IP。我在这里遵循:https://docs.traefik.io/user-guide/kubernetes/,似乎没有提到关闭
每当我尝试docker组成任何项目时,都会出现以下错误。 我尝试过有和没有sudo 我在这台机器上只有这个问题。我可以在Mac和Amazon WorkSpace上运行相同的容器。 (myslabs)
我正在尝试 pip install stanza 并收到此消息: ERROR: No matching distribution found for torch>=1.3.0 (from stanza
DNS 解析看起来不错,但我无法 ping 我的服务。可能是什么原因? 来自集群中的另一个 Pod: $ ping backend PING backend.default.svc.cluster.l
我正在使用Hibernate 4 + Spring MVC 4当我开始 Apache Tomcat Server 8我收到此错误: Error creating bean with name 'wel
我是一名优秀的程序员,十分优秀!