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

Pir Fahim Shah
  • 10,505
  • 1
  • 82
  • 81
  • Not clear what you want. Open as in read its bytes or you just want to display it to the user? – Zig Mandel Apr 05 '14 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... – Pir Fahim Shah Apr 05 '14 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. – Pir Fahim Shah Apr 07 '14 at 06:48

1 Answers1

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)

Pir Fahim Shah
  • 10,505
  • 1
  • 82
  • 81