DownloadManager: Understand retry policies and error codes.

According to the documentation , if the download failed due to an http error - it COLUMN_REASONshould contain a special http error code.

The problem I am facing is that in practice the only reason I see when loading fails is ERROR_HTTP_DATA_ERROR

also, I see in logcat the actual HTTP error code at runtime when the download stops and retries, but I see no way to get it from the download manager.

is there any way to get this http code?

I use the broadcast receiver for processing ACTION_DOWNLOAD_COMPLETE, but I don’t see a way to listen to the pause, and I get the feeling that if I try to explain the reason for the boot manager error between retries, I will get the actual status code.

Is it possible to listen to the download pause event without a constant request from the download manager?

I expect it to be such a broadcast.

The questions I would very much like to receive answers to are the following:

  • Is it possible to listen to the download pause event without a constant request from the download manager and without an active listener for the content recognizer?
  • - does the download manager (at API level 16+) support https (ssl)?
  • What is the download manager reload policy? can i change its default repeat policy?
+4
1

- http-?

. DownloadManager STATUS_SUCCESSFUL , , url/ (HTTP 404) ( ).
. DownloadManager STATUS_SUCCESSFUL

, , . 5 , .


" " ?

, . "" : enter image description here

, X ,

if (cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)) == DownloadManager.STATUS_PAUSED) {
    // Do stuff
}

- ( API 16+) https (ssl)?

https ( Android DownloadManager SSL (https)), . , https, https://mdn.mozillademos.org/files/3794/mixed_content_webconsole.jpg. , .


? ?

. . , , .

, : com.android.providers.downloads.Constants. 5.1.1, , . - android 4.0.1 ( , 5.1.1).

:

, , , .

public static final int MAX_RETRIES = 5;

, Retry-After -.

public static final int MIN_RETRY_AFTER = 30; // 30s

, Retry-After -.

public static final int MAX_RETRY_AFTER = 24 * 60 * 60; // 24h

, () , , .


: DownloadManager , .

< > : downloadmanager https://github.com/Trinea/android-common < > , 2k + stars github , .

+8

Source: https://habr.com/ru/post/1608182/


All Articles