Android browser download manager - android

Can I use android build-in browser download manager to download files in my application?
In case of audio files, opening remote file url using Intent.ACTION_VIEW with data type "audio/*" causes browser to start playback, but I'd like to force download of specified file.

The download manager is not part of the public SDK. You are welcome to download files from URLs via HttpURLConnection or HttpClient, both part of the Android SDK.

I am wondering exactly the same. It seems like a waste of time to write a service which handles download/resume/checking connection etc, when I just want to say downloadFile(URL myURL). Is there anything that could be re-used? Android Market also has a downloader...

http://developer.android.com/reference/android/app/DownloadManager.html
Can some one tell what is this? If download Manager isnt a part of SDK.
Seems to me like a complete download manager. I will try this soon.

Related

Make app generated content show in stock android Downloads app

We are working on an android app that generates PDFs based on app contents on users' request. We are providing an option to launch an email agent and attach the generate PDF, but we also want the user be able to view the document later at any time. On android, there are no stock file explorer, so our first thought was to show on the stock Downloads app's file list. We've tried the following two methods but without luck.
We firstly tried to save the PDF to the default download folder (given by calling Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)) and invoke media scanner, but the file doesn't show up in the Downloads app's list. It's shown in Adobe Acrobat's local document list though.
After some research, it seems that the Downloads app would only show files that downloaded though DownloadManager, so we tried to generate the PDF in a temporary directory and call DownloadManager to download it, but, somehow expected, it complains that we can only download via HTTP(S), so this approach isn't working as well.
Is there any other solution?
well if you have to provide access to the document without any file explorer app, i think your approach is correct it to allow to store it in the Download lists. To achive this you can use Nanohttpd in your application to host your pdf document and then invoke the DownloadManager download action using HTTP(S) to your webapp (you will have to create a small webapp to handle the download request) hosted on localhost server.

Android - Download HTML file from URL

I'm building an app which is supposed to download (and later on) display an html file.
I don't need to worry about supporting files like CSS/JS.
I enqueue the file via its URL (eg. http://www.noodle.com/index.html) to the Android Donwload Manager but the download always fails.
Any ideas how to get the file? Or how to convince the Manager to download it properly?
You can make use of HTTPClient provided by Android to use it
More details on how to save that to file is available at
How do I use the Simple HTTP client in Android?

android - where does WebView download its files to?

I am implementing a simple download system in the embedded webview, by intercepting the click using shouldOverrideUrlLoading and then call:
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse(url));
startActivity(intent);
This opens the native browser, shows an indicator that the file is being downloaded, and once it's completed I can pull down the notification list to view the file. I have several questions though:
Where does WebView download its files to?
Is this a temporary cache or is it persistent? Can I access it offline?
How can my WebView gets informed when the download completes?
Ultimately what I'm trying to achieve is that, once the file is downloaded, the next time the user clicks to the link, it will open up the local downloaded file, instead of trying to download it again.
Looking at the emulator through the DDMS perspective in Eclipse it looks like the files are downloaded to either yourAppsNamespace/cache/webviewCache or actually into the yourAppsNamespace/databases/ . So the file should be a permanent download. As to knowing when the download is complete i am not sure

How to launch the Android Download Manager

How do I start default phone's download manager, like the one builtin in default browser? I need to create an intent that contains url of file to download. I know it's possible, as I saw some applications doing it in the past.
What you want is DownloadManager.
Browsing the Android source code reveals that the default browser is using this as well.
EDIT
You can browse the source code for DownloadManager here and try to use the code to make it work on 7. Bare in mind the dependencies of the class might also be not available on 7 (most probably) but it might be worth a look.
As easy as:
startActivity(new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS));

what is the problem with android while downloading? can any one figure out?

The following link downloads a file from a site.it works fine in desktop browser. but it is not working in android default browser and in webview code(i used download listener too but not working).
I believe the Android default browser can't download .zip files by default (you should get a "This content is not supported" error).
If you want to download certain files through your own application though, you can try this this solution.
What code do you use? Could you specify it? I suggest you downloading it in AsyncTask via HTTP. Where do you save it? What is the error log? So many questions =)

Categories

Resources