简体   繁体   English

Drive API清单以及与Drive App的集成

[英]Drive API manifest and integration with Drive App

I have an Android app that creates its own files in Google Drive with the mime type application/vnd.test.type 我有一个Android应用,可以使用mime类型的application/vnd.test.type在Google云端硬盘中创建自己的文件

I would like to make my app handle requests for this file type when opened by the Google Drive app as described here . 我想描述当由谷歌云端硬盘应用打开,让我的应用程序处理的请求此文件类型在这里

My activity to handle the opening of the file is in my manifest file as follows: 我处理文件打开的活动在我的清单文件中,如下所示:

    <activity android:name="DriveHandlerActivity" 
              android:label="@string/app_name" 
              android:icon="@drawable/icon" 
              android:exported="true" >
        <meta-data android:name="com.google.android.apps.drive.APP_ID" 
                   android:value="id=MY_ID"/> 
        <intent-filter >
            <action android:name="com.google.android.apps.drive.DRIVE_OPEN"/>
            <data android:mimeType="application/vnd.test.type"/>
        </intent-filter>
    </activity> 

When I attempt to open the file in the Google Drive app I get the "Open with..." dialog as expected with my app listed as the only entry capable of dealing with this file type. 当我尝试在Google云端硬盘应用中打开文件时,我会按预期启用“打开方式...”对话框,我的应用列表是唯一能够处理此文件类型的条目。 Unfortunately after confirming the action, I then get a dialog thats says. 不幸的是,在确认了这个动作之后,我得到了一个对话框。

错误对话框

My only option then is to press the "Cancel" button which returns me to the Google Drive app. 我唯一的选择是按“取消”按钮,将我返回到Google云端硬盘应用。

I am not totally convinced I have the meta data correct as the ID is referred to using different names depending on where you look. 我并不完全相信我的元数据是正确的,因为ID会根据您的外观使用不同的名称来引用。 Some documentation calls it the App ID , some call it the Project ID (See here at 26:44) . 有些文档将其称为App ID ,有些称之为Project ID (请参阅此处26:44) I have tried using both the "Project ID" as listed in my Google Apis Console and also the project number (from the URL) on the same page. 我尝试使用我的Google Apis控制台中列出的“项目ID”以及同一页面上的项目编号(来自URL)。 I get the same error regardless of which value I choose as the ID. 无论我选择哪个值作为ID,我都会得到相同的错误。

As far as I am aware, the next step should be to handle the intent in my app but due to the error described, the intent never arrives. 据我所知,下一步应该是在我的应用程序中处理意图,但由于所描述的错误,意图永远不会到来。 Can anybody tell me what I am doing incorrectly? 谁能告诉我我做错了什么?

There's currently an issue that requires your application to be listed in the Chrome Webstore (even to trusted testers only) in order for the Open With flow to work. 目前存在一个问题,要求您的应用程序列在Chrome Webstore中 (即使只限于受信任的测试人员),以便Open With流程能够正常运行。

However, even if the issue is resolved, your app won't be able to access the file until the Google Play Services API is released. 但是,即使问题已解决,在您发布Google Play Services API之前,您的应用仍无法访问该文件。 The only work around would be to request authorization for the full Drive scope https://www.googleapis.com/auth/drive which is not recommended but useful for debugging. 唯一的解决方法是请求完整的驱动器范围https://www.googleapis.com/auth/drive授权,这不建议用于调试。

I'll update this answer when the Chrome Webstore limitation is resolved. 当Chrome Webstore限制得到解决后,我会更新此答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM