Android 从Google驱动器打开自定义文件失败

Android 从Google驱动器打开自定义文件失败,android,google-drive-api,Android,Google Drive Api,我的应用程序创建了具有自定义Mime类型的文件,并将其存储在Google Drive上。应用程序也可以搜索并重新打开这些文件。但是,当我在Google Drive应用程序(不是我自己的应用程序)中单击文件时,打开的流不起作用 选择器的意图与预期一样显示,仅列出了我的应用程序,但当我选择我的应用程序时,Google Drive应用程序会短暂显示一个从未启动的下载进度条,然后显示存在内部错误 我的设置如下,我希望有人能告诉我这是什么原因。虽然我认为目前没有任何东西与我的应用程序联系。据我所知,开发人

我的应用程序创建了具有自定义Mime类型的文件,并将其存储在Google Drive上。应用程序也可以搜索并重新打开这些文件。但是,当我在Google Drive应用程序(不是我自己的应用程序)中单击文件时,打开的流不起作用

选择器的意图与预期一样显示,仅列出了我的应用程序,但当我选择我的应用程序时,Google Drive应用程序会短暂显示一个从未启动的下载进度条,然后显示存在内部错误

我的设置如下,我希望有人能告诉我这是什么原因。虽然我认为目前没有任何东西与我的应用程序联系。据我所知,开发人员控制台已正确填写

清单

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="...">
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="@drawable/logo" android:label="@string/app_name"
    android:allowBackup="true" android:theme="@style/AppTheme">
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <activity android:name=".MainActivity" android:label="@string/app_name"
        android:launchMode="singleTop" android:theme="@style/AppTheme">
        <meta-data android:name="com.google.android.apps.drive.APP_ID" android:value="id=..." />
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.google.android.apps.drive.DRIVE_OPEN" />
            <data android:mimeType="@string/app_mime" />
            <data android:mimeType="@string/file_mime" /> <!-- matches the file im clicking -->
        </intent-filter>
    </activity>
</application>

经过一些测试后,在驱动器应用程序连接到服务器以检索信息并将其传递给其他应用程序(或任何其他故障)之间出现超时后,似乎会发生这种情况

最初的问题会给你一个有意义的错误,但是驱动器应用程序似乎维护了一个缓存或其他东西,在以后的所有尝试中都会显示上述错误

解决方案是要么清除两个应用程序的数据(这可能会有问题),要么(我发现更容易)重新安装您正在开发/测试的应用程序。任何一种方法都可以阻止此问题再次发生

public class MainActivity extends Activity {

private static final String ACTION_DRIVE_OPEN = "com.google.android.apps.drive.DRIVE_OPEN";
private static final String EXTRA_DRIVE_OPEN_ID = "resourceId";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ...
}

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);
}

@Override
protected void onResume() {
    super.onResume();
    handleIntent();
}

private void handleIntent() {
    Intent intent = getIntent();
    if (ACTION_DRIVE_OPEN.equals(intent.getAction())) {
        if (intent.getType().equals(getString(R.string.file_mime))) {
            String fileId = intent.getStringExtra(EXTRA_DRIVE_OPEN_ID);
            if (fileId != null && !"".equals(fileId)) {
                ...
            } else {
                Log.e(TAG, "Drive_Open has no valid file id - " + fileId);
            }
        } else {
            Log.e(TAG, "Drive_Open called on the wrong mime type - " + intent.getType() + " found, " + getString(R.string.file_mime) + " required");
        }
    }
}