如何捕捉/听在Android网页浏览器下载 [英] How to catch/listen on android web browser downloads

查看:144
本文介绍了如何捕捉/听在Android网页浏览器下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的Andr​​oid应用程序,监听浏览器的意图,以赶上他们在某些类型的URI,每当用户点击。更具体地讲,我想我的应用程序打开时,用户点击指向一个torrent文件(IG HTTP超链接://地方/ file.torrent )。

I have my android application that listens for browser intents in order to catch them whenever user click on certain type of URI. More specifically, I want my app to open when user clicked on a hyperlink that point to a torrent file (i.g. http://somewhere/file.torrent).

请参阅我下面的意图过滤器从我的应用程序的Andr​​oidManifest.xml:

See below my intent filters from my application AndroidManifest.xml :

        <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:mimeType="application/x-bittorrent"
                android:scheme="http" />
        </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:host="*"
                android:pathPattern=".*\\.torrent"
                android:scheme="http" />
        </intent-filter>

这工作得很好,只要超级链接点文件的位置。 但是 - 有时网址直接指向该文件是由服务器PTED跨$ P $返回要下载的文件基于某种ID像这个链接的 http://www.mininova.org/get/13202308 返回回文件。在这种情况下,我的意图过滤器不工作,和Android浏览器下​​载文件,而不是打开我的应用程序和传球意图与文件URI。

This works well as long as the hyperlink point the file location. BUT - sometimes URLs directly point to the file and is interpreted by the server to return the file to download based on some kind of id like this link http://www.mininova.org/get/13202308 which returns the file back. In that case, my intent-filters doesn't work, and the android browser download the file instead of open my app and passing an intent with the file URI.

有没有人有关于如何得到文件的线索URI?

Does anyone has a clue on how to get the file URI?

感谢

推荐答案

这是可能的,在这种情况下的HTTP响应有头内容处置:附件;文件名= file.torrent

It is possible that on those cases the http response has the header Content-disposition: as attachment;filename=file.torrent

如果是这样的话有可能是浏览器甚至不抛出意图。

If that's the case is possible that the browser doesn't even throw an intent.

这篇关于如何捕捉/听在Android网页浏览器下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆