[英]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.