Downloading file from google drive using fileMetadata.getWebContentLink() - android

I am trying to download a file(it could be any file like image,pdf,text etc) using fileMetadata.getWebContentLink()
when i print this link it shows something like this:
https://drive.google.com/uc?id=0Bw6vr2LNxB3iUFJrTk5oZDljaTA&export=download
When i put this link into my desktop's browser the file is automatically downloaded. but i cant download this into my app.
I used this link to download using new DownloadFileAsync().execute(fileMetadata.getWebContentLink());
When i make the file public to access in my google drive then it works otherwise it doesn't work.
Can anyone know why is this happening and how to fix this??

WebcontentLink only works in browsers.
Here's the steps to download a file in your app as it is stated here
Retrieve the Drive File object and open the file contents. (Content is binary)
Read the content with Input Stream, save it and close it.

Related

displaying pdf in xamarin android

I am trying to create an app that will be able to display a pdf file in the app itself. I'm currently using the Xamarin.Bindings.PDFView-Android by SIDOVSKY which works really nicely. I can open a file easily from the assets... what I'm struggling to do is open a file from the internet.
Just a single line of code:
FindViewById<PDFView>(Resource.Id.pdf_view).FromAsset("report.pdf").Show();
Is enough to display a PDF that can be pinched to zoom which is great. However, I now want to access a file stored on the local network. Either using a SMB share, or through the intranet. Whichever way I try I can't figure it out.
There is a .FromFile setting, but I can't get it to work by putting a smb path in here. Is there a way to convert this? Or must I download the file to the local device first?
Thanks
Andrew

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.

How to Download mp3 file from google drive in android

I am working on Android application in which i have to download audio files from google drive and then save these files in sd-card.. Is there any api or sample project that helps me in downloading mp3 files from google drive
OR
Is there any other way to to download mp3 file from google drive programatically...
Can we use public downloadable url for achieving above mentioned purpose
Thanks
There are two a APIs that that allow you to do it. The GDAA and the REST. None of them deals with the mp3 files specifically, though. The APIs deal with a binary file content only. That means you:
Find the file first. Either you know the name, mime type,... or you know it's Id. If you use REST, the Id can be extracted from the file's URL.
Download the content as a binary stream.
Save the content as an mp3 file on Android.
If you insist on applying the URL based Id, it is easier to use the REST, since:
the URL directly corresponds with the REST Id (aka ResourceId in GDAA)
you can use the REST playground (bottom) to test things interactively
Also, you may use the demo code here to see the (dis)advantages of using one API or another. It deals with jpg content instead of mp3, but it has all the building blocks you need. Be sure you understand the relation of DriveId and ResourceId.
Good Luck
Go to Developers Google Website click here
you will get information how to download file.

How to get http url of downloaded file in android?

I am trying to find a way to get http-url of downloaded file in android. Is there anyway to do it ?
I have looked around DownloadManager, but it seems not appropriate for this scenario.
e.g. if we open browser with link : http://www.xyz.com/myapp.apk?param1=abc
and now after downloading and installing apk.
In same application (when it starts) I need to get -> param1=abc.
Any kind of help will be appreciated!
Thanks
Personnaly, I think that the downloaded url is not stored in the .apk file. The apk file is a portable file and can be downloaded from different url addresses and the web browser will not add a metadata to the apk file.

Web link to download with Android phone?

In my web site i make link likeDOWNLOAD. And when i open this site on my Android phone and click on link, standart browser opens txt file. I want to download file and not open.
What i may to do for that?
Thanks!
I think you need to set MIME type set on your server setting.
By default, the text.txt is linked with a viewer hence if will download and open.
Secondly, it would be stored in downloads folder on your sdcard.

Categories

Resources