gpt4 book ai didi

android - 如何捕捉/收听 Android 网络浏览器下载

转载 作者:太空宇宙 更新时间:2023-11-03 10:53:55 26 4
gpt4 key购买 nike

我有我的 android 应用程序,它监听浏览器 Intent ,以便在用户单击某种类型的 URI 时捕获它们。更具体地说,我希望我的应用程序在用户单击指向 torrent 文件的超链接(例如 http://somewhere/file.torrent )时打开。

请参阅下面来 self 的应用程序 AndroidManifest.xml 的 Intent 过滤器:

        <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>

只要超链接指向文件位置,它就可以正常工作。但是 - 有时 URL 直接指向文件并由服务器解释以返回文件以根据某种 id 下载,如此链接 http://www.mininova.org/get/13202308返回文件。在那种情况下,我的 intent-filters 不起作用,android 浏览器下载文件而不是打开我的应用程序并通过文件 URI 传递 intent。

有没有人知道如何获取文件 URI?

谢谢

最佳答案

在这些情况下,http 响应可能具有 header Content-disposition: 作为 attachment;filename=file.torrent

如果是这种情况,浏览器甚至可能不会抛出 intent。

关于android - 如何捕捉/收听 Android 网络浏览器下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8762600/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com