download-manager

Download manager does not work on LG devices

[亡魂溺海] 提交于 2019-12-12 10:38:27
问题 I try to perform downloading the file using DownloadManager. Everything works fine except LG devices. Here is my code: private void downloadFile(FileInfo fileInfo) { private DownloadManager manager = (DownloadManager) MyApp.getSingleton(). getApplicationContext().getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager.Request request = new DownloadManager.Request(Uri.parse("https://" + MyPreference.getInstance().getBaseUrl() + "/api/v3/files/" + fileId + "/get")); request.setDescription

Android DownloadManager “Impossible to open file”

谁都会走 提交于 2019-12-12 08:09:11
问题 I'm using DownloadManager to download a file from a webService. The download end successfuly, but when I try to open the new file in the "download" folder I've got this error "Impossible to open file" (and I know I can open this type of file). Also, when I plug my phone to my computer and when I open the download file with it, the file open successfuly and is not corrupted. I don't have other error, so I'm really lost ! Here my code: /*Data*/ int filePosition = position - _subFolderNameList

Android: Save data to internal memory using Download

独自空忆成欢 提交于 2019-12-12 03:39:17
问题 I am downloading file from a server in Android using the DownloadManager class. I want to store this file in the internal memory of the device. I tried to use .setDestinationInExternalPublicDir(Environment.getExternalStorageDirectory() +"/Android/data/xxx.xxx.xxx/files/") as mentioned here, but it is not working. How to solve my problem? 回答1: add <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> to manifest.xml and create "/Android/data/xxx.xxx.xxx/files/" path 回答2:

Opening a file downloaded with DownloadManager

大憨熊 提交于 2019-12-11 11:59:01
问题 I'm trying to open a file downloaded using DownloadManager. I'm getting the local filename after download is finished. After that I suggest my user to open file (or decline). The method I use for opening file is: private void openFile(String fileName) { MimeTypeMap map = MimeTypeMap.getSingleton(); String ext = MimeTypeMap.getFileExtensionFromUrl((fileName)); String type = map.getMimeTypeFromExtension(ext); Intent install = new Intent(Intent.ACTION_VIEW); Log.d(TAG, "openFile Trying to open

How to identify which file triggered Download_Complete intent

£可爱£侵袭症+ 提交于 2019-12-11 01:55:46
问题 I'm developing an application that will Download another apk file, and asks for it's installation. Since my target is GingerBread I'm using the DownloadManager class. Is there anyway to know which downloaded file triggered the DOWNLOAD_COMPLETE intent? 回答1: It's stored in EXTRA_DOWNLOAD_ID: public static final String EXTRA_DOWNLOAD_ID Since: API Level 9 Intent extra included with ACTION_DOWNLOAD_COMPLETE intents, indicating the ID (as a long) of the download that just completed. Constant

Android Oreo (API26) and android.app.DownloadManager

妖精的绣舞 提交于 2019-12-10 19:28:27
问题 Folks! This code doesn't work on Android Oreo (but ok on older versions, I can see notifications and the DownloadManager.ACTION_DOWNLOAD_COMPLETE broadcast message). Kotlin testButton.setOnClickListener { val downloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager val uri = Uri.parse("[url for a mp3 file]") val request = DownloadManager.Request(uri) request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI) request.setAllowedOverRoaming(false) request

In Download manager, how to get status when its “cancel” from notification bar?

╄→гoц情女王★ 提交于 2019-12-10 17:41:39
问题 I am using download manger to download file in android. But in the case of when tap on "cancel" button from the notification bar , I am unable to get any broadcast. I have find only two broadcast : 1. DownloadManager.ACTION_DOWNLOAD_COMPLETE 2. DownloadManager.ACTION_NOTIFICTION_CLICKED Is there any broadcast by Download manager when its cancel ? If not then please give me any solution how to handle it ? 回答1: DownloadManager will write information to database when it handle the user download

Calculating current (not average) download speed

陌路散爱 提交于 2019-12-09 13:24:52
问题 In my download manager application, I'm using the code below to calculate the current transfer rate: TimeSpan interval = DateTime.Now - lastUpdateTime; downloadSpeed = (int)Math.Floor((double)(DownloadedSize + cachedSize - lastUpdateDownloadedSize) / interval.TotalSeconds); lastUpdateDownloadedSize = DownloadedSize + cachedSize; lastUpdateTime = DateTime.Now; This mostly works the way I want (I'm updating the speed every 4 seconds or so), but there are always some crazy spikes in the download

Android Download Manager

限于喜欢 提交于 2019-12-09 04:51:52
问题 I think i have a rather simple question. http://www.vogella.com/blog/2011/06/14/android-downloadmanager-example/ I have been following a tutorial in the above url. How do I change the filepath for downloads? Thanks in Advance 回答1: You configure the DownloadManager.Request object with that sort of information. In the tutorial, that Request object is created and used in onClick() . For example: DownloadManager.Request req=new DownloadManager.Request(uri); req.setAllowedNetworkTypes

Set extras for DownloadManager's BroadcastReceiver [duplicate]

♀尐吖头ヾ 提交于 2019-12-08 20:19:17
问题 This question already has answers here : Pass data to BroadcastReceiver from Activity using DownloadManager (4 answers) Closed 3 years ago . There's a way to put extras in DownloadManager 's intent registered for action DownloadManager.ACTION_DOWNLOAD_COMPLETE (e.g. receive a boolean value set as extra in the intent)? This is how I create the request: DownloadManager.Request req = new DownloadManager.Request(myuri); // set request parameters //req.set... DownloadManager downloadManager =