0

I am building an android application where i am getting files from my Google drive. Now i am success while fetching files from Drive. But now, what actually i want to do is to open/display that files using Google Drive Viewer.Like if when i click on the file which i have fetched from Drive then it should be display to the user, For example if it is an image file and when i click over it in my application, then it should be open and display using Google Drive Viewer. I don't know how to use/embed Google Drive Viewer for an android application. please help

3
  • Not clear what you want. Open as in read its bytes or you just want to display it to the user? Commented Apr 5, 2014 at 17:19
  • @ZigMandel I want to display my file, like if i have an image file then it should display to user, or if it is a text file then text should display to user etc... Commented Apr 5, 2014 at 17:58
  • @ImranKhan Actually i am retrieving different files from my DRIVE (like image,pdf,text etc). I can retrieve this file but now i want to display these file like when i click on image file like "imag.png" then it should open in image viewer same for text and pdf file. Commented Apr 7, 2014 at 6:48

1 Answer 1

0

Ok, i got solution myself for this problem. If you want to open any file which you have retrieved from Drive, then this can be done easily while using the resources of Google Drive app. First of all install the Google Drive app from play market Install Google Drive

After that use this code to open your file.

 FileID=file.getId();//it is your file ID which you want to display String url = "https://docs.google.com/file/d/"+FileID; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); 

This will open your file of any type(image, pdf,doc,txt etc)

Sign up to request clarification or add additional context in comments.

1 Comment

Can this solution work offline? or is it only available when you have an internet connection?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.