【问题标题】:Android intent filter file type httpAndroid Intent 过滤器文件类型 http
【发布时间】:2016-02-02 11:58:25
【问题描述】:

我在我的应用程序中注册了一个意图过滤器来打开文件类型“.m3u”,它适用于使用文件浏览器选择的本地文件,但在这些情况下它不会在“打开方式”菜单上显示我的应用程序:

  • 如果我点击“m3u”文件的链接
  • 如果我下载“m3u”文件,然后单击通知栏打开下载文件(否则,如果我浏览下载文件并单击它,我的应用程序将出现在“打开方式”菜单中。李>

这里是我设置意图的 Manifest 文件部分

 <!-- LOCAL FILE -->
            <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:host="*"
                    android:mimeType="*/*"
                    android:pathPattern=".*\\.m3u"
                    android:scheme="file" />
            </intent-filter>
<!--             HTTP FILE -->
            <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:host="*"
                    android:mimeType="*/*"
                    android:pathPattern=".*\\.m3u"
                    android:scheme="http" />
            </intent-filter>

我错过了什么?

谢谢

【问题讨论】:

  • 嗨@Pecana,我在想你的android:pathPattern=".*\\.m3u"。看看this thread。我怀疑这会解决您的问题。
  • 不幸的是它对我不起作用:-(我尝试了这个和其他类似的解决方案,但似乎没有任何效果:-(
  • 抱歉,经过一些更改后一切正常 :-) 顺便说一句,当我从通知栏中单击下载的文件时,我仍然无法打开文件。单击通知栏打开文件和浏览文件并单击它有什么区别?谢谢
  • 嗨@Pecana,我可以请您发布您的解决方案并接受它作为答案吗?这可能会帮助其他有类似问题的人(也可以帮助我了解您是如何解决它的)。 =) 现在关于您的问题,我相信您可能需要创建一个PendingIntent 并将其设置为您的Notification。我相信this guide 可以解决你提到的通知栏问题。
  • 嗨@AuroMetal 我明白你的意思,但这不是我的情况:-) 我不必使用 PendingIntent 处理我自己的通知,我需要的是更不同的。如果我现在从浏览器单击 m3u 链接,我可以处理请求并且意图过滤器正在工作,问题是当您从站点单击链接并且浏览器下载文件时,在通知栏上“下载的文件通知”出现,如果我点击它打开文件,意图过滤器不起作用:-(还有其他我想念的过滤器吗?内容或类似的东西??

标签: android file android-intent types filter


【解决方案1】:

这里是本地文件(使用文件管理器浏览)、http 和 https 的工作解决方案 :-)

<!-- LOCAL FILE -->
            <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:host="*"
                    android:mimeType="*/*"
                    android:pathPattern=".*\\.m3u"
                    android:scheme="file" />
                <data
                    android:host="*"
                    android:mimeType="*/*"
                    android:pathPattern=".*\\.m3u"
                    android:scheme="file" />
                <data
                    android:host="*"
                    android:mimeType="*/*"
                    android:pathPattern=".*\\.M3U"
                    android:scheme="file" />
                <data
                    android:host="*"
                    android:mimeType="*/*"
                    android:pathPattern=".*\\.M3u"
                    android:scheme="file" />
                <data
                    android:host="*"
                    android:mimeType="*/*"
                    android:pathPattern=".*\\.m3U"
                    android:scheme="file" />
            </intent-filter>

            <!-- HTTP FILE -->
            <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:host="*"
                    android:pathPattern=".*\\.m3u8"
                    android:scheme="http" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\.m3u8"
                    android:scheme="http" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\..*\\.m3u8"
                    android:scheme="http" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\..*\\..*\\..m3u8"
                    android:scheme="http" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\..*\\..*\\..*\\.m3u8"
                    android:scheme="http" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\.m3u"
                    android:scheme="http" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\..*\\.m3u"
                    android:scheme="http" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\..*\\..*\\..m3u"
                    android:scheme="http" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\..*\\..*\\..*\\.m3u"
                    android:scheme="http" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\.m3u8"
                    android:scheme="https" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\.m3u8"
                    android:scheme="https" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\..*\\.m3u8"
                    android:scheme="https" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\..*\\..*\\..m3u8"
                    android:scheme="https" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\..*\\..*\\..*\\.m3u8"
                    android:scheme="https" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\.m3u"
                    android:scheme="https" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\..*\\.m3u"
                    android:scheme="https" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\..*\\..*\\..m3u"
                    android:scheme="https" />
                <data
                    android:host="*"
                    android:pathPattern=".*\\..*\\..*\\..*\\.m3u"
                    android:scheme="https" />
            </intent-filter>

我仍在寻找下载文件的解决方案..

【讨论】:

  • 你尝试过这些分类吗:
猜你喜欢
  • 2012-01-29
  • 1970-01-01
  • 1970-01-01
  • 2013-09-26
  • 2014-09-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-15
  • 2014-08-12
相关资源
最近更新 更多