安卓:直接从浏览器下载文件 [英] Android: Download file directly from browser

查看:265
本文介绍了安卓:直接从浏览器下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让Android浏览器下​​载一个特定类型的.XXX'说,这样我就可以设置一个应用程序来与它相关的文件。

I'm trying to make the android browser download a file of a specific type '.xxx’ say, so that I can then set an app to be associated with it.

我已经成功地完成了协会的一部分,在这样点击右边类型在资源管理器应用程序的文件加载相应的应用程​​序,我已经做到了。我预计今年结转到浏览器,这样,如果我试图下载一个文件类型.XXX那么它会打开应用程序。

I've successfully done the association part, in that I've made it so that clicking on a file of the right type in an explorer app loads the appropriate app. I expected this to carry over to the browser so that if I attempted to download a file type .xxx then it would open the app.

这不会发生,发生的事情是,文件中包含的文本显示在浏览器中。我已经成立了天文(应用/ XXXX)MIME类型链接,该但这要么没有什么区别。它必须能够做我想做的,因为如果我点击比如浏览器下载它,并给我开了PDF阅读器的选项。一个PDF文件

This doesn’t happen, all that happens is that the text contained in the file is displayed in the browser. I've set up a mime type link for this in astro (application/xxxx) but this has made no difference either. It must be possible to do what I want because If I click on a pdf file for instance the browser downloads it and gives me the option to open a pdf reader.

推荐答案

您需要添加一个<意向滤光器> 中的标签 <接收器GT; 在你的应用程序清单标签

You need to add an <intent-filter> tag within a <receiver> tag in your Application Manifest.

这是如何工作如下:

  1. Android的广播意图

  1. Android broadcasts an intent

该系统的搜索能够接收这一意图的应用程序列表

The system searches a list of applications capable of receiving that intent

该系统查询用户选择一个应用程序来处理的意图

The system queries the user to select an application to handle that intent

用户选择一个应用程序,或者被默认为pre-指定的应用程序

The user selects an application, or is defaulted to a pre-specified application

应用程序打开

看看的接收元件,文档看有关如何实现这更多的细节。

Take a look at the receiver element docs to see more details about how to implement this.

奥莱如果你需要更多的帮助。

Holler if you need more help.

感谢

这篇关于安卓:直接从浏览器下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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