TileCache listeners never called

699
2
02-03-2017 10:25 AM
HenrikPierrou
New Contributor II

Hi,

In my app using ArcGIS Runtime SDK for Android 100.0.0 I’m loading a local TileCache from a TPK file into my MapView as a basemap. Before loading the TileCache I’m adding a “DoneLoadingListener” (Runnable) and a LoadStatusChangedListener to the TileCache to get notified when the loading is done. It is my understanding that these listeners should be called whether the loading succeeds or not and that by checking the LoadStatus on the TileCache I can tell if it loaded successfully or not. On some occasions though, seemingly randomly, the callbacks aren’t called at all. What may cause the callbacks to not be called and how can I monitor what is going on if I can’t get notified using the listeners?

Here is the code

File baseMap = getPermanentPathForMapType(MapDataType.BASE_MAP);
TileCache tileCache = new TileCache(baseMap.getPath());
tileCache.loadAsync();
tileCache.addDoneLoadingListener(new Runnable() {
    @Override
   
public void run() {
        Log.i(TAG, "LOAD DONE"); // Sometimes not called
    }
});
tileCache.addLoadStatusChangedListener(new LoadStatusChangedListener() {
    @Override
   
public void loadStatusChanged(LoadStatusChangedEvent loadStatusChangedEvent) {
        Log.i(TAG, "LOAD STATUS CHANGED TO " + loadStatusChangedEvent.getNewLoadStatus().toString()); // Sometimes not called
    }
});
Log.i(TAG, tileCache.getLoadStatus().toString()); // LOADING

Regards,

Henrik

0 Kudos
2 Replies
AlexanderNohe1
Occasional Contributor III

Have you tried moving the loadAsync() method to below the StatusChangedListeners?

0 Kudos
HenrikPierrou
New Contributor II

Hi Alexander,

 

Yes I have but unfortunately it doesn't make a difference. And it shouldn't, according to the docs. If the cache has already loaded when the listener is added the DoneLoadingListener method (run) should be called immediately.

 

Since the loading failed randomly I'm leaning towards it being a timing issue of some kind. What I did as a workaround was to create a separate class that repeatedly attempts to load the cache in the background until succeeding.

Regards

Henrik

0 Kudos