用于打开本地文件的Intent过滤器

时间:2018-02-28 22:08:44

标签: android android-intent text-files uri intentfilter

我正在努力完成[简单]任务。

我有一个与文本文件(或任何类似文本的文件)一起使用的活动。 我需要从像这样的简单意图(无架构)运行它:

am start -a my.ACTION -d "/sdcard/file.txt"

不幸的是我得到了:

unable to resolve Intent

我尝试使用简单的过滤器:

        <intent-filter>
            <action android:name="my.ACTION" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

但它不起作用。我尝试添加mimeType,pathPatterns等,但没有成功。

如果我使用:

        <intent-filter>
            <action android:name="my.ACTION" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="file" />
        </intent-filter>

am start -a my.ACTION -d "file:///sdcard/file.txt"

然后一切正常。 有解决方案吗?我阅读了Intent过滤器文档,但没有找到任何。

0 个答案:

没有答案