简体   繁体   中英

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

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. 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.

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. Some documentation calls it the App ID , some call it the Project ID (See here at 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. I get the same error regardless of which value I choose as the 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.

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. 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.

I'll update this answer when the Chrome Webstore limitation is resolved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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