Небольшой вопрос о менеджере загрузки в android. Это первый раз, когда я работаю с ним и успешно загрузил несколько файлов и открыл их. Но мой вопрос заключается в том, как проверить, завершена ли загрузка.Менеджер загрузок Android завершен
Ситуация заключается в том, что я загружаю PDF-файл и открываю его, и обычно файл настолько мал, что он заканчивается перед открытием. Но если файл несколько больше, то как я могу проверить, закончил ли диспетчер загрузки загрузку перед ее открытием.
Как скачать:
Intent intent = getIntent();
DownloadManager downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
Uri Download_Uri = Uri.parse(intent.getStringExtra("Document_href"));
DownloadManager.Request request = new DownloadManager.Request(Download_Uri);
//Restrict the types of networks over which this download may proceed.
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
//Set whether this download may proceed over a roaming connection.
request.setAllowedOverRoaming(false);
//Set the title of this download, to be displayed in notifications.
request.setTitle(intent.getStringExtra("Document_title"));
//Set the local destination for the downloaded file to a path within the application's external files directory
request.setDestinationInExternalFilesDir(this,Environment.DIRECTORY_DOWNLOADS,intent.getStringExtra("Document_title") + ".pdf");
//Enqueue a new download and same the referenceId
Long downloadReference = downloadManager.enqueue(request);
Как открыть файл
Uri uri = Uri.parse("content://com.app.applicationname/" + "/Download/" + intent.getStringExtra("Document_title") + ".pdf");
Intent target = new Intent(Intent.ACTION_VIEW);
target.setDataAndType(uri, "application/pdf");
target.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(target);
Так где-то между загрузкой и открытием файла Я хочу, если заявление, чтобы проверить, если он должен продолжать или ждать файл.
Проверка данного руководства HTTP://www.gadgetsaint.com/android/download-manager/ – ASP