我已经写了下面的意图过滤器来使用我的应用程序打开一个文本文件。它似乎有效,但有时只是。例如,如果我通过电子邮件发送文本文件,如果选择从邮件打开,我的应用程序不会显示。如果我先选择保存,然后打开,我的应用程序将显示。与下拉框类似的经验,如果我尝试从下拉框打开,我的应用程序将不会被列为可以打开,但如果我从下拉框导出到SD并使用文件管理器打开它,我的应用程序被列出并且作品。Android意图过滤器
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="*" android:pathPattern=".*\\.txt" />
<data android:scheme="https" android:host="*" android:pathPattern=".*\\.txt" />
<!-- <data android:scheme="content" android:host="*" android:pathPattern=".*\\.txt" /> -->
<data android:scheme="file" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.txt" />
</intent-filter>
我试着添加但仍然没有成功 – user1013448
编辑我的答案包括什么数据元素应该看起来像。这应该是您需要考虑的视图操作。 –
这似乎工作 – user1013448