【问题标题】:How can i get image file from google drive programatically on android?如何在 android 上以编程方式从谷歌驱动器获取图像文件?
【发布时间】:2016-04-22 17:09:15
【问题描述】:

您好,我正在打开从设备获取图像文件的简单意图:

 Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);//
                startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_IMAGE_FIRST);

它工作正常,直到我从设备、图库或 SD 卡中选择图像,但它也为我提供了谷歌驱动器,如果我从那里选择图像,它会停止整个应用程序。

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=41, result=-1, data=Intent { dat=content://com.google.android.apps.docs.storage/document/acc=1;doc=3310 flg=0x1 }} to activity

如何从谷歌驱动器获取图像(文件)?

在我得到图片后,我得到了文件的路径,然后我通过改造上传它。

【问题讨论】:

    标签: android


    【解决方案1】:

    目前您不能在 Google 云端硬盘中使用 ACTION_GET_CONTENT。谷歌在旧版本中错误地支持它。但是最新版本的 Drive (1.1.470.15) Intent 已被禁用,并且 ACTION_GET_CONTENT 不会抛出 Drive 作为选项。

    【讨论】:

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