BackStack上碎片上的加载器未保留

时间:2016-07-06 21:32:59

标签: android android-fragments

最近,我一直试图通过服务器缓存数据来改善我的Android应用程序。经过一番研究后,我决定使用Loader Pattern,因为它可以解决很多情况。

使用com.android.support:appcompat-v7:23.4.0

我设法让装载程序在设备旋转时保存响应,或者在遍历Back Stack时重新显示项目。

问题是当我在Activities Fragment Manager的Back Stack上放置一些片段时,旋转设备,然后开始备份Back Stack。

重新显示这些重新显示的片段加载器,而不是在第一次显示时使用加载器。

以下是LoaderManager.enableDebugLogging(true);的输出:

V/LoaderManager: initLoader in LoaderManager{8ddafd2 in HostCallbacks{6208a3}}: args=null
V/LoaderManager:   Created new loader LoaderInfo{97187a0 #0 : DemoAppLoader{269af59}}
V/LoaderManager: Starting in LoaderManager{8ddafd2 in HostCallbacks{6208a3}}
V/LoaderManager:   Starting: LoaderInfo{97187a0 #0 : DemoAppLoader{269af59}}
D/DemoApp: MainActivity: -> http://jsonplaceholder.typicode.com/posts {"body":"Post 0: 
D/DemoApp: MainActivity: <- http://jsonplaceholder.typicode.com/posts {
                          "body": "Post 0: Nothing here!",
                          "title": "Fake 0",
                          "user_id": 0,
                          "id": 101
                        }
V/LoaderManager: onLoadComplete: LoaderInfo{97187a0 #0 : DemoAppLoader{269af59}}
V/LoaderManager:   onLoadFinished in DemoAppLoader{269af59 id=0}: Response{fde91b}
E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f75650179a0
V/LoaderManager: Stopping in LoaderManager{8ddafd2 in HostCallbacks{6208a3}}
V/LoaderManager:   Stopping: LoaderInfo{97187a0 #0 : DemoAppLoader{269af59}}
V/LoaderManager: initLoader in LoaderManager{3e8cbf6 in HostCallbacks{6208a3}}: args=null
V/LoaderManager:   Created new loader LoaderInfo{e87fbf7 #1 : DemoAppLoader{6b5ba64}}
V/LoaderManager: Starting in LoaderManager{3e8cbf6 in HostCallbacks{6208a3}}
V/LoaderManager:   Starting: LoaderInfo{e87fbf7 #1 : DemoAppLoader{6b5ba64}}
D/DemoApp: MainActivity: -> http://jsonplaceholder.typicode.com/posts {"body":"Post 1: 
D/DemoApp: MainActivity: <- http://jsonplaceholder.typicode.com/posts {
                          "body": "Post 1: Nothing here!",
                          "title": "Fake 1",
                          "user_id": 0,
                          "id": 101
                        }
V/LoaderManager: onLoadComplete: LoaderInfo{e87fbf7 #1 : DemoAppLoader{6b5ba64}}
V/LoaderManager:   onLoadFinished in DemoAppLoader{6b5ba64 id=1}: Response{1cdb182}
E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f7565017a10
V/LoaderManager: Retaining in LoaderManager{3e8cbf6 in HostCallbacks{6208a3}}
V/LoaderManager:   Retaining: LoaderInfo{e87fbf7 #1 : DemoAppLoader{6b5ba64}}
V/LoaderManager: Destroying Active in LoaderManager{8ddafd2 in HostCallbacks{6208a3}}
V/LoaderManager:   Destroying: LoaderInfo{97187a0 #0 : DemoAppLoader{269af59}}
V/LoaderManager:   Reseting: LoaderInfo{97187a0 #0 : DemoAppLoader{269af59}}
V/LoaderManager: Destroying Inactive in LoaderManager{8ddafd2 in HostCallbacks{6208a3}}
V/LoaderManager: Destroying Active in LoaderManager{8ddafd2 in HostCallbacks{6208a3}}
V/LoaderManager: Destroying Inactive in LoaderManager{8ddafd2 in HostCallbacks{6208a3}}
V/LoaderManager: Destroying Inactive in LoaderManager{3e8cbf6 in HostCallbacks{6208a3}}
E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f7565017930
V/LoaderManager: initLoader in LoaderManager{3e8cbf6 in HostCallbacks{5abbb3d}}: args=null
V/LoaderManager:   Re-using existing loader LoaderInfo{e87fbf7 #1 : DemoAppLoader{6b5ba64}}
V/LoaderManager: Starting in LoaderManager{3e8cbf6 in HostCallbacks{5abbb3d}}
V/LoaderManager:   onLoadFinished in DemoAppLoader{6b5ba64 id=1}: Response{1cdb182}
V/LoaderManager: Finished Retaining in LoaderManager{3e8cbf6 in HostCallbacks{5abbb3d}}
V/LoaderManager:   Finished Retaining: LoaderInfo{e87fbf7 #1 : DemoAppLoader{6b5ba64}}
V/LoaderManager:   onLoadFinished in DemoAppLoader{6b5ba64 id=1}: Response{1cdb182}
E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f7565017cb0
E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f7565017460
V/LoaderManager: Stopping in LoaderManager{3e8cbf6 in HostCallbacks{5abbb3d}}
V/LoaderManager:   Stopping: LoaderInfo{e87fbf7 #1 : DemoAppLoader{6b5ba64}}
V/LoaderManager: Destroying Active in LoaderManager{3e8cbf6 in HostCallbacks{5abbb3d}}
V/LoaderManager:   Destroying: LoaderInfo{e87fbf7 #1 : DemoAppLoader{6b5ba64}}
V/LoaderManager:   Reseting: LoaderInfo{e87fbf7 #1 : DemoAppLoader{6b5ba64}}
V/LoaderManager: Destroying Inactive in LoaderManager{3e8cbf6 in HostCallbacks{5abbb3d}}
V/LoaderManager: Destroying Active in LoaderManager{3e8cbf6 in HostCallbacks{5abbb3d}}
V/LoaderManager: Destroying Inactive in LoaderManager{3e8cbf6 in HostCallbacks{5abbb3d}}
V/LoaderManager: initLoader in LoaderManager{b5dd22c in HostCallbacks{5abbb3d}}: args=null
V/LoaderManager:   Created new loader LoaderInfo{70414f5 #0 : DemoAppLoader{59dc28a}}
V/LoaderManager: Starting in LoaderManager{b5dd22c in HostCallbacks{5abbb3d}}
V/LoaderManager:   Starting: LoaderInfo{70414f5 #0 : DemoAppLoader{59dc28a}}
D/DemoApp: MainActivity: -> http://jsonplaceholder.typicode.com/posts {"body":"Post 0: 
D/DemoApp: MainActivity: <- http://jsonplaceholder.typicode.com/posts {
                          "body": "Post 0: Nothing here!",
                          "title": "Fake 0",
                          "user_id": 0,
                          "id": 101
                        }
V/LoaderManager: onLoadComplete: LoaderInfo{70414f5 #0 : DemoAppLoader{59dc28a}}
V/LoaderManager:   onLoadFinished 

1 个答案:

答案 0 :(得分:0)

this related issue修复了许多片段问题,例如24.0.0 version。我怀疑升级到该版本会解决您的问题。