简体   繁体   English

通过文件扩展名在我的 Android 应用程序中打开来自 Google Drive 的文件

[英]Opening files from Google Drive in my Android app by file extension

So I managed to get my app to open files with a specific extension from file managers, but is it possible for users to tap on the file in Google Drive and have it open in the same way?所以我设法让我的应用程序从文件管理器打开具有特定扩展名的文件,但是用户是否可以点击 Google Drive 中的文件并以相同的方式打开它? I mean I know it's possible, other apps do it but what would be the steps to do this?我的意思是我知道这是可能的,其他应用程序可以这样做,但是执行此操作的步骤是什么? I'm not interested in my app being able to manipulate files on Google Drive in any way, just to have Google Drive "send" the files to my app the way file managers do.我对我的应用程序能够以任何方式操作 Google Drive 上的文件不感兴趣,只是让 Google Drive 像文件管理器那样将文件“发送”到我的应用程序。

This is the intent filter I'm using now, but it doesn't work for files in Google Drive:这是我现在使用的意图过滤器,但它不适用于 Google Drive 中的文件:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
            <action android:name="com.google.android.apps.drive.DRIVE_OPEN" />              
    <data android:scheme="file" />
    <data android:mimeType="*/*" />
    <data android:pathPattern=".*\\.xz9" />
    <data android:host="*" />
</intent-filter>

I tested it myself for my app.我自己为我的应用程序测试了它。 You need to add this intent-filter to your activity so your app can be listed when the user clicks on a file inside the Google Drive app regardless of the file's extension.您需要将此intent-filter添加到您的活动中,以便在用户单击 Google Drive 应用程序内的文件时可以列出您的应用程序,而不管文件的扩展名如何。

<intent-filter>
    <action
        android:name="android.intent.action.VIEW" />

    <action
        android:name="android.intent.action.EDIT" />

    <category
        android:name="android.intent.category.DEFAULT" />

    <category
        android:name="android.intent.category.BROWSABLE" />

    <data
        android:scheme="file" />

    <data
        android:scheme="content" />

    <data
        android:mimeType="application/plain" />

    <data
        android:mimeType="application/octet-stream" />

    <data
        android:mimeType="text/*" />
</intent-filter>

暂无
暂无

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

相关问题 在我的Android应用中管理Google云端硬盘上的文件 - Managing files on Google Drive in my Android app 如何将Android应用程序与具有特定扩展名的Google云端硬盘文件相关联? - How to associate Android app with Google Drive files having particular extension? 将Google云端硬盘实施到Android应用并从Google云端硬盘下载文件 - Google Drive Implementation to Android app and Downloading the file from Google drive 将文件从Android应用上传到Google驱动器 - Upload file from android app to google drive 从我的Android应用程序打开Goog​​le Maps - Opening Google Maps from my Android app 从Android上的谷歌驱动器打开自定义文件扩展名 - Open custom file extension from google drive on android 如何在我的cordova phonegap android应用上从Google云端硬盘获取文件和文件夹列表? - How to get list of files and folders from Google Drive on my cordova phonegap android app? 如何仅使用Google Android应用中的Google Drive API在Google云端硬盘上创建和编辑电子表格文件? - How do I create & edit a spreadsheet file on google drive using Google Drive APIs only from my Android app? Google Drive Android API如何将音频文件上传到我的驱动器? 如何同步驱动器文件? - Google Drive Android API how to upload a audio file to my drive ? How to sync drive files? 如何将文件从Google云端硬盘上传到我的应用? - How to upload files from Google Drive to my app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM