android-download-manager

How to Enable Android Download Manager

拟墨画扇 提交于 2019-11-30 10:28:26
问题 I'm using Android Download Manager to download list of files. Lately I came across a crash report saying Unknown java.lang.IllegalArgumentException: Unknown URL content://downloads/my_downloads Then later, I figured it out that the reason is because user disabled Android Download Manager. I check if the Download Manager is disabled by checking it's package name with the code below. int state = this.getPackageManager().getApplicationEnabledSetting("com.android.providers.downloads"); And now, I

Unzipping files programmatically in Android

做~自己de王妃 提交于 2019-11-30 07:47:59
I am downloading a zip folder and saving in specific folder in my Android device. My application is not accessing the folder as it is zipped. I would like to unzip the folder after downloading from server and save in specific folder. And my code is here: public void DownloadDatabase(String DownloadUrl, String fileName) { try { File root = android.os.Environment.getExternalStorageDirectory(); File dir = new File(root.getAbsolutePath() + "/timy/databases"); if(dir.exists() == false){ dir.mkdirs(); } URL url = new URL("http://myexample.com/android/timy.zip"); File file = new File(dir,fileName);

Android ProgressBar in ListView while using DownloadManager

℡╲_俬逩灬. 提交于 2019-11-30 07:24:39
I have a ListView in which each item represents a PDF file. When the user clicks on an item, the application must download the file on external storage. Now the download doesn't work properly, but that's not the question. I want a ProgressBar, spinning wheel style, to appear next to each item of the list while the file is downloaded. My problem is : I can't find how to make the spinning wheel appear. Before the Download Manager I tried it with an AsyncTask and the spinning wheel worked. Here is my code : CategoryActivity.java (Activity of the ListView) @Override public void onItemClick

How to download multiple files concurrently using intentservice in Android?

亡梦爱人 提交于 2019-11-30 04:33:30
I want to create a service similar to this one, (reference from Here ), to download multiple files asynchronously in Android. public static class DownloadingService extends IntentService { public static String PROGRESS_UPDATE_ACTION = DownloadingService.class .getName() + ".newDownloadTask"; private ExecutorService mExec; private CompletionService<NoResultType> mEcs; private LocalBroadcastManager mBroadcastManager; private List<DownloadTask> mTasks; public DownloadingService() { super("DownloadingService"); mExec = Executors.newFixedThreadPool( 3 ); // The reason to use multiple thread is to

How to Enable Android Download Manager

天涯浪子 提交于 2019-11-29 20:37:15
I'm using Android Download Manager to download list of files. Lately I came across a crash report saying Unknown java.lang.IllegalArgumentException: Unknown URL content://downloads/my_downloads Then later, I figured it out that the reason is because user disabled Android Download Manager. I check if the Download Manager is disabled by checking it's package name with the code below. int state = this.getPackageManager().getApplicationEnabledSetting("com.android.providers.downloads"); And now, I need to find a way to enable the Download Manager if it is disabled. I tried setting it's enable state

Android ProgressBar in ListView while using DownloadManager

点点圈 提交于 2019-11-29 09:34:12
问题 I have a ListView in which each item represents a PDF file. When the user clicks on an item, the application must download the file on external storage. Now the download doesn't work properly, but that's not the question. I want a ProgressBar, spinning wheel style, to appear next to each item of the list while the file is downloaded. My problem is : I can't find how to make the spinning wheel appear. Before the Download Manager I tried it with an AsyncTask and the spinning wheel worked. Here

Unzipping files programmatically in Android

 ̄綄美尐妖づ 提交于 2019-11-29 03:59:37
问题 I am downloading a zip folder and saving in specific folder in my Android device. My application is not accessing the folder as it is zipped. I would like to unzip the folder after downloading from server and save in specific folder. And my code is here: public void DownloadDatabase(String DownloadUrl, String fileName) { try { File root = android.os.Environment.getExternalStorageDirectory(); File dir = new File(root.getAbsolutePath() + "/timy/databases"); if(dir.exists() == false){ dir.mkdirs

Show Download Manager progress inside activity

吃可爱长大的小学妹 提交于 2019-11-28 21:24:52
I used Download Manager class inside my activity to perform downloads; it works fine and my next task is to show the same progress percentage inside my activity. I am not sure how to do it. My code so far public class DownloadSampleBook extends Activity{ private long enqueue; private DownloadManager dm; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sample_download); BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context

Android DownloadManager get filename

点点圈 提交于 2019-11-28 20:24:34
In my app you can download some files. I used the Android DownloadManager class for downloading. After the download is completed, it should show me a message that the file was downloaded. The problem is, there could be 2,3 or 4 downloads at the same time. My BroadcastReceiver code looks like this: receiver_complete = new BroadcastReceiver(){ @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE) ){ Toast.makeText(MainActivity.this, MainActivity.this.getString(R.string.download_finished,

DownloadManager IllegalStateException creating a download in DIRECTORY_DOWNLOADS

ぐ巨炮叔叔 提交于 2019-11-28 09:17:36
Firstly, there are a lot of questions on this subject, but none reflect my issue. I have for example read this and this . The issue that I have, is that in an extremely small number of cases, my function to setDestinationInExternalPublicDir results in the following stack trace: Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.onlinetvrecorder.otrapp2.listeners.DownloadUpdateReceiver: java.lang.IllegalStateException: Unable to create directory: /mnt/sdcard/Download at android.app.ActivityThread.handleReceiver(ActivityThread.java:2274) at android.app.ActivityThread