0
當我下載地圖時,它說我需要1299個資源數才能完成它。但是當項目數達到1298/1299時。它卡住了。基本上它始終堅持在99.9%。離線地圖可查看和使用,但我的用戶界面和我的下載服務永久卡住,等待onStatusChanged()
的回調達到100%。MapBox下載離線區域卡在99.9%
在調試器,我收到此日誌:
03-10 09:19:10.034 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 98.84526558891454% items 1284/1299
03-10 09:19:10.054 23981-29834/com.indigo.android.shoreleave V/com.mapbox.mapboxsdk.http.HTTPRequest: [HTTP] Request was successful (code = 200).
03-10 09:19:10.054 23981-29860/com.indigo.android.shoreleave V/com.mapbox.mapboxsdk.http.HTTPRequest: [HTTP] Request was successful (code = 200).
03-10 09:19:10.064 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 98.92224788298691% items 1285/1299
03-10 09:19:10.064 23981-29858/com.indigo.android.shoreleave V/com.mapbox.mapboxsdk.http.HTTPRequest: [HTTP] Request was successful (code = 200).
03-10 09:19:10.074 23981-30075/com.indigo.android.shoreleave V/com.mapbox.mapboxsdk.http.HTTPRequest: [HTTP] Request was successful (code = 200).
03-10 09:19:10.134 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 98.99923017705927% items 1286/1299
03-10 09:19:10.154 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 99.07621247113164% items 1287/1299
03-10 09:19:10.184 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 99.153194765204% items 1288/1299
03-10 09:19:10.214 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 99.23017705927637% items 1289/1299
03-10 09:19:10.254 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 99.30715935334872% items 1290/1299
03-10 09:19:10.274 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 99.38414164742109% items 1291/1299
03-10 09:19:10.304 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 99.46112394149345% items 1292/1299
03-10 09:19:10.334 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 99.53810623556582% items 1293/1299
03-10 09:19:10.374 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 99.61508852963819% items 1294/1299
03-10 09:19:10.454 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 99.69207082371055% items 1295/1299
03-10 09:19:10.484 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 99.7690531177829% items 1296/1299
03-10 09:19:10.514 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 99.84603541185527% items 1297/1299
03-10 09:19:10.564 23981-23981/com.indigo.android.shoreleave I/ShoreLeaveApplication: From service: Downloading id [email protected] 99.92301770592763% items 1298/1299
03-10 09:19:20.604 23981-27396/com.indigo.android.shoreleave D/GzipRequestInterceptor: Compressing
03-10 09:19:22.564 23981-27396/com.indigo.android.shoreleave D/MapboxEventManager: response code = 204 for events 2
日誌太長,雖然,所以我只需要我的日誌從90-99.9。正如你可以從日誌的末尾看到(99.9%,一千二百九十九分之一千二百九十八)它說:
D/GzipRequestInterceptor: Compressing
03-10 09:19:22.564 23981-27396/com.indigo.android.shoreleave D/MapboxEventManager: response code = 204 for events 2
這裏是我的代碼:
private OfflineManager.CreateOfflineRegionCallback mOnCreateOfflineRegionCallback = new OfflineManager.CreateOfflineRegionCallback()
{
@Override
public void onCreate(final OfflineRegion offlineRegion)
{
offlineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE);
offlineRegion.setObserver(new OfflineRegion.OfflineRegionObserver()
{
@Override
public void onStatusChanged(OfflineRegionStatus status)
{
double percentage = status.getRequiredResourceCount() >= 0 ? (100.0 * status.getCompletedResourceCount()/status.getRequiredResourceCount()) : 0.0;
long mapID = offlineRegion.getID();
Intent intent = new Intent();
intent.putExtra(Extras.MAP_DOWNLOAD_ID, mapID);
intent.putExtra(Extras.DOWNLOAD_PERCENTAGE, percentage);
intent.putExtra(Extras.DOWNLOAD_REQUIRED_RESOURCE_COUNT, status.getRequiredResourceCount());
intent.putExtra(Extras.DOWNLOAD_COMPLETED_RESOURCE_COUNT, status.getCompletedResourceCount());
intent.putExtra(Extras.IS_DOWNLOAD_COMPLETE, status.isComplete());
intent.putExtra(Extras.IS_DOWNLOAD_STEP_SUCCESS, true);
intent.putExtra(Extras.IS_DOWNLOAD_FAILED, false);
intent.putExtra(Extras.DOWNLOAD_STATE, status.getDownloadState());
mIsFinished.put(mapID, status.isComplete());
try
{
JSONObject jsonObject = new JSONObject(new String(offlineRegion.getMetadata(), Charset.forName("UTF-8")));
intent.putExtra(Extras.MAP_NAME, jsonObject.getString(Extras.MAP_NAME));
}
catch (JSONException e)
{
e.printStackTrace();
}
ShoreLeaveCacheManager.insertOrUpdate(Utils.getDownloadStatusFromIntent(intent));
createOrUpdateNotification(intent);
if(mOnDownloadCallback != null)
mOnDownloadCallback.onDownloadProgress(intent);
if(mIsFinished.containsKey(mapID) && mIsFinished.get(mapID))
ShoreLeaveCacheManager.save(OfflineMapDownloadService.this.getApplicationContext(), ShoreLeaveCacheManager.CACHE_DOWNLOAD_STATUS);
if(isAllDownloadFinished())
{
stop();
mHasStarted = false;
}
Log.i(ShoreLeaveApplication.TAG, "From service: Downloading id "
+ mapID + "@ " + percentage
+ "% items " + status.getCompletedResourceCount()
+ "/" + status.getRequiredResourceCount());
}
@Override
public void onError(OfflineRegionError error)
{
Intent intent = new Intent(Constants.BROADCAST_OFFLINE_MAP_DOWNLOAD_STATUS);
intent.putExtra(Extras.MAP_DOWNLOAD_ID, offlineRegion.getID());
intent.putExtra(Extras.IS_DOWNLOAD_COMPLETE, false);
intent.putExtra(Extras.IS_DOWNLOAD_STEP_SUCCESS, false);
intent.putExtra(Extras.IS_DOWNLOAD_FAILED, true);
intent.putExtra(Extras.DOWNLOAD_STATE, OfflineRegion.STATE_INACTIVE);
ShoreLeaveCacheManager.insertOrUpdate(Utils.getDownloadStatusFromIntent(intent));
ShoreLeaveCacheManager.save(OfflineMapDownloadService.this.getApplicationContext(), ShoreLeaveCacheManager.CACHE_DOWNLOAD_STATUS);
mIsFinished.remove(offlineRegion.getID());
createOrUpdateNotification(intent);
// LocalBroadcastManager.getInstance(OfflineMapDownloadService.this.getBaseContext()).sendBroadcast(intent);
if(mOnDownloadCallback != null) mOnDownloadCallback.onDownloadProgress(intent);
if(isAllDownloadFinished())
{
stop();
mHasStarted = false;
}
mNotificationManager.notify(1000 + ((int) offlineRegion.getID()), Utils.buildOfflineMapDownloadServiceNotification(OfflineMapDownloadService.this, intent, "Failed... "));
}
@Override
public void mapboxTileCountLimitExceeded(long limit)
{
Intent intent = new Intent(Constants.BROADCAST_OFFLINE_MAP_DOWNLOAD_STATUS);
intent.putExtra(Extras.MAP_DOWNLOAD_ID, offlineRegion.getID());
intent.putExtra(Extras.IS_DOWNLOAD_COMPLETE, false);
intent.putExtra(Extras.IS_DOWNLOAD_STEP_SUCCESS, false);
intent.putExtra(Extras.IS_DOWNLOAD_FAILED, true);
intent.putExtra(Extras.DOWNLOAD_STATE, OfflineRegion.STATE_INACTIVE);
ShoreLeaveCacheManager.insertOrUpdate(Utils.getDownloadStatusFromIntent(intent));
ShoreLeaveCacheManager.save(OfflineMapDownloadService.this.getApplicationContext(), ShoreLeaveCacheManager.CACHE_DOWNLOAD_STATUS);
mIsFinished.remove(offlineRegion.getID());
// LocalBroadcastManager.getInstance(OfflineMapDownloadService.this.getBaseContext()).sendBroadcast(intent);
if(mOnDownloadCallback != null)
mOnDownloadCallback.onDownloadProgress(intent);
if(isAllDownloadFinished())
{
stop();
mHasStarted = false;
}
mNotificationManager.notify(1000 + ((int) offlineRegion.getID()), Utils.buildOfflineMapDownloadServiceNotification(OfflineMapDownloadService.this, intent, "Failed... "));
}
});
if(mOnDownloadCallback != null)
mOnDownloadCallback.onOfflineRegionCreated(offlineRegion);
}
@Override
public void onError(String error)
{
// LocalBroadcastManager.getInstance(OfflineMapDownloadService.this).sendBroadcast(new Intent(Constants.BROADCAST_OFFLINE_MAP_DOWNLOAD_STATUS));
}
};
如果這是我的結束。可能它只是一個錯誤。我仍在檢查。如果不是,這是正常的嗎?有什麼想法嗎?
嗨Cammace,請看看我的編輯。 –
NVM,您可以選擇關閉此問題。它似乎是一個錯誤,現在似乎已經修復了。 –