アプリを使用してテキストファイルを開くために、以下のインテントフィルターを作成しました。それはうまくいくようですが、たまにしかありません。たとえば、テキストファイルをメールで送信する場合、メールから開くを選択すると、アプリが表示されません。最初に保存を選択してから開くと、アプリが表示されます。ドロップボックスでの同様の経験。ドロップボックスから開こうとすると、アプリは開くことができると表示されませんが、ドロップボックスからsdにエクスポートし、ファイルマネージャーを使用して開くと、アプリが表示され、動作します。
<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>