mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

(Android) Cancel or pause offlineRegion download.

Open vfaSonnt opened this issue 10 years ago • 3 comments

I know many people ask for this feature but there is no answer. So I need to ask again.

In issue #5408 ,he suggest to stop offlineRegion on next one. I think he don't get the point. We want to stop/pause on current offlineRegion, not the next one. I only download 1 offline region, it took more than 3 minutes for 600 resources. If in the middle of downloading process, I press back to Android HomeScreen and launch app again. My activity can not start, it have to wait until previous offlineRegion finish download. This is a real problem because it freeze my app. My user can not use the app until downloading process finish.

I try these on onDestroy() function. But it is no help.

            mOfflineRegion.setDownloadState(OfflineRegion.STATE_INACTIVE);
            mOfflineRegion.setObserver(null);
            mOfflineRegion.delete(new OfflineRegion.OfflineRegionDeleteCallback() {
                @Override
                public void onDelete() {

                }

                @Override
                public void onError(String error) {

                }
            });

vfaSonnt avatar Jun 23 '16 04:06 vfaSonnt

mOfflineRegion.setDownloadState(OfflineRegion.STATE_INACTIVE); is the correct way to pause the download of an offline region. Can you describe more precisely what is the issue you are having with it?

jfirebaugh avatar Jul 06 '16 17:07 jfirebaugh

@vfaSonnt: As @jfirebaugh points out above, mOfflineRegion.setDownloadState(OfflineRegion.STATE_INACTIVE) is a valid strategy to pause the region download in your activity. Are you getting any errors in the log that you could share with us? I'm curious if its async nature isn't working well with the Android lifecycle.

Another possible strategy that we see often in these situations is to use a Service to handle the download in the background. That way the download can continue even if the activity goes inactive, and it doesn't get affected by a new activity launch. In your particular use case, a simple IntentService should be able to do the trick.

zugaldia avatar Jul 06 '16 19:07 zugaldia

Thank you! I use Service to handle Download.

vfaSonnt avatar Aug 03 '16 02:08 vfaSonnt