Xamarin-CrossDownloadManager icon indicating copy to clipboard operation
Xamarin-CrossDownloadManager copied to clipboard

[Android] Stop download tasks without custom location when app is killed or crashes

Open SimonSimCity opened this issue 9 years ago • 1 comments

There is some code in the Android version, that should be used for re-initializing download-tasks that haven't finished while the app was running.

As we can't surely say which tasks belong to our app when restarting the app (the browser may also has some items in there) and the filter for running, paused and queued tasks doesn't work on Android 4.x (see #33), I think the best option we currently have is to stop all downloads that are done against the temporary location.

The downloads that are going to a custom location cannot be queried but you can see that they finished by the time the file is already downloaded.

I'm also working on a check for re-initializing an ongoing download if you try to download the file again. The system then throws an error that this file already is queued and we'll just catch it up, because it was in the native queue, but not in the queue of this lib.

This is just required as long as we use Androids implementation of the DownloadManager. #34 would make this request invalid.

SimonSimCity avatar Nov 22 '16 07:11 SimonSimCity

Because we don't have an event when the app stops, we can set our own event by running a service:

  • http://stackoverflow.com/questions/25207383/stop-android-service-when-app-is-closed-with-the-task-manager
  • http://stackoverflow.com/questions/24406508/how-to-detect-application-exit-on-android
  • http://stackoverflow.com/questions/19568315/how-to-handle-code-when-app-is-killed-by-swiping-in-android

SimonSimCity avatar Nov 24 '16 10:11 SimonSimCity