【问题标题】:Open a file in Google Drive programmatically not using Drive API不使用 Drive API 以编程方式在 Google Drive 中打开文件
【发布时间】:2013-12-30 16:16:14
【问题描述】:
【问题讨论】:
标签:
android
google-drive-api
【解决方案1】:
现在别担心,我有解决这个问题的办法。如果您想打开从 Drive 中检索到的任何文件,则可以在使用 Google Drive 应用程序的资源时轻松完成。首先从 Play Market Install Google Drive app 安装 Google Drive 应用程序
之后使用此代码打开您的文件。
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);
这将打开您的任何类型的文件(图像、pdf、doc、txt 等)
【解决方案2】:
你可以写:
String url="https://docs.google.com/a/spreadsheet/ccc?key=0AoDnOTP7MiABdF9VSEFNMktmeDY4MkNHS3NDdk5JMmc#gid=0";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
另外,您不需要下载 googleDrive。任何知道该链接的人都可以访问该文件或文件夹