- 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/
我最近在/ drawable中添加了一些.gifs,以便可以将它们与按钮一起使用。这个工作正常(没有错误)。现在,当我重建/运行我的应用程序时,出现以下错误: Error: Gradle: Execu
Android 中有返回内部存储数据路径的方法吗? 我有 2 部 Android 智能手机(Samsung s2 和 s7 edge),我在其中安装了一个应用程序。我想使用位于这条路径中的 sqlit
这个问题在这里已经有了答案: What's the difference between "?android:" and "@android:" in an android layout xml f
我只想知道 android 开发手机、android 普通手机和 android root 手机之间的实际区别。 我们不能从实体店或除 android marketplace 以外的其他地方购买开发手
自Gradle更新以来,我正在努力使这个项目达到标准。这是一个团队项目,它使用的是android-apt插件。我已经进行了必要的语法更改(编译->实现和apt->注释处理器),但是编译器仍在告诉我存在
我是android和kotlin的新手,所以请原谅要解决的一个非常简单的问题! 我已经使用导航体系结构组件创建了一个基本应用程序,使用了底部的导航栏和三个导航选项。每个导航选项都指向一个专用片段,该片
我目前正在使用 Facebook official SDK for Android . 我现在正在使用高级示例应用程序,但我不知道如何让它获取应用程序墙/流/状态而不是登录的用户。 这可能吗?在那种情
我在下载文件时遇到问题, 我可以在模拟器中下载文件,但无法在手机上使用。我已经定义了上网和写入 SD 卡的权限。 我在服务器上有一个 doc 文件,如果用户单击下载。它下载文件。这在模拟器中工作正常但
这个问题在这里已经有了答案: What is the difference between gravity and layout_gravity in Android? (22 个答案) 关闭 9
任何人都可以告诉我什么是 android 缓存和应用程序缓存,因为当我们谈论缓存清理应用程序时,它的作用是,缓存清理概念是清理应用程序缓存还是像内存管理一样主存储、RAM、缓存是不同的并且据我所知,缓
假设应用程序 Foo 和 Eggs 在同一台 Android 设备上。任一应用程序都可以获取设备上所有应用程序的列表。一个应用程序是否有可能知道另一个应用程序是否已经运行以及运行了多长时间? 最佳答案
我有点困惑,我只看到了从 android 到 pc 或者从 android 到 pc 的例子。我需要制作一个从两部手机 (android) 连接的 android 应用程序进行视频聊天。我在想,我知道
用于使用 Android 以编程方式锁定屏幕。我从 Stackoverflow 之前关于此的问题中得到了一些好主意,并且我做得很好,但是当我运行该代码时,没有异常和错误。而且,屏幕没有锁定。请在这段代
文档说: android:layout_alignParentStart If true, makes the start edge of this view match the start edge
我不知道这两个属性和高度之间的区别。 以一个TextView为例,如果我将它的layout_width设置为wrap_content,并将它的width设置为50 dip,会发生什么情况? 最佳答案
这两个属性有什么关系?如果我有 android:noHistory="true",那么有 android:finishOnTaskLaunch="true" 有什么意义吗? 最佳答案 假设您的应用中有
我是新手,正在尝试理解以下 XML 代码: 查看 developer.android.com 上的文档,它说“starStyle”是 R.attr 中的常量, public static final
在下面的代码中,为什么当我设置时单选按钮的外观会发生变化 android:layout_width="fill_parent" 和 android:width="fill_parent" 我说的是
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
假设我有一个函数 fun myFunction(name:String, email:String){},当我调用这个函数时 myFunction('Ali', 'ali@test.com ') 如何
我是一名优秀的程序员,十分优秀!