【问题标题】:Open a file in Google Drive programmatically not using Drive API不使用 Drive API 以编程方式在 Google Drive 中打开文件
【发布时间】:2013-12-30 16:16:14
【问题描述】:

我有一个接收 Google Drive File URL 的应用程序。像这样的:

https://docs.google.com/a/spreadsheet/ccc?key=0AoDnOTP7MiABdF9VSEFNMktmeDY4MkNHS3NDdk5JMmc#gid=0

我仍然不确定是完整的 https url 还是只有键值

我需要做两件事:

1) 检查手机中是否安装了适用于 Android 的 Google Drive Application。

2) 使用该 URL 调用 Google Drive Android 应用程序以打开文件。理想的方式是不打开任何网络浏览器。我想使用带有附加功能的 Intent 之类的东西,这可能吗?

谢谢你的帮助,对不起我的英语不好

【问题讨论】:

    标签: 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。任何知道该链接的人都可以访问该文件或文件夹

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多