- Where Developers Learn, Share, & Build Careers
I have the following problem: whenever I download the file containing DownloadManager it is downloaded twice (save in the" Fashion "file name Here's my code: Unfortunately, DownloadManager is the cart and does not work correctly reports your problem on all the devices here Done:
Public Zero Downloads () {Request Request = New Request (Uri.parse (_wrapper.getURL)) ); Request.setTitle (getFileName (_wrapper.getURL ())); Request.setVisibleInDownloadsUi (wrong); Request.setDestinationInExternalFilesDir (_context, null, "/" + getFileName (_wrapper.getURL ())); _downloadID = _downloadManager.enqueue (requested); } Public BroadcastReceiver getDownloadFinishedBroadcastReceiver () {BroadcastReceiver Receiver = New BroadcastReceiver () {@Override Public Zero onReceive (context pContext, intent pIntent) {string action = pIntent.getAction (); If (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals (verb)) {query query = new query (); Query.setFilterById (_downloadID); Cursor cursor = _downloadManager.query (query); If (cursor.moveToFirst ()) {file file = new file (ScrulloidConstants.APPLICATION_DIRECTORY); Int position = cursor.gate (cursor.gatecolumns index (DownloadManager.COLUMN_STATUS)); If (position == DownloadManager.STATUS_SUCCESSFUL) {string path = cursor.getString (cursor.getColumnIndex (DownloadManager.COLUMN_LOCAL_FILENAME)); _wrapper.setFilePath (path); _wrapper.setLastDownloaded (new date ()); If (! _listener = null) {_listener.onDownloadProjectTaskFinished (New TaskResult & lt; ProjectWrapper & gt; (_ wrapper)); }} Else if (position == DownloadManager.STATUS_FAILED) {int cause = cursor.getInt (cursor.getColumnIndex (DownloadManager.COLUMN_REASON)); DownloadFailedException ex = New DownloadFailedException (Reason); If (_Listener = Null) {_listener.onDownloadProjectTaskFinished (New Task Resolve ProjectWrapper _wrapper is just a simple class that holds data, no arguments have been made. _listener simply shows little toast message on callback method I debug my app download () method is applied only once I hope you get me the error Can help in finding.
Comments
Post a Comment