[英]When any browser saves a file on android, is there a broadcast sent? How can I intercept saved/downloaded files in a browser on Android?
I want to create an application where users can choose to save a file into my application and go through an activity to do so. 我想创建一个应用程序,用户可以选择将文件保存到我的应用程序中,并通过一个活动来进行操作。
I'm brand new to Android programming, but I've been a Java developer for quite a while. 我是Android编程的新手,但我从事Java开发已有相当一段时间了。 After reading some of the documentation I've seen that the way I'd probably go about this is via a Broadcast Receiver, or something involving intents.
在阅读了一些文档之后,我发现我可能通过广播接收器或其他涉及意图的方法来解决这个问题。
The exact thing I'd like to see on the phone: 我想在电话上看到的确切内容:
I'm curious as to exactly how I would achieve this. 我很好奇我将如何实现这一目标。
- Users holds finger down on image in the browser
用户将手指放在浏览器中的图像上
- User chooses to download (or some other choice as created by my application)
用户选择下载(或由我的应用程序创建的其他选择)
You are welcome to write your own Web browser, where you control what happens when the user long-presses on an image. 欢迎您编写自己的Web浏览器,在其中您可以控制用户长按图像时发生的情况。 The authors of other Web browsers will control what happens when the user long-presses on an image in their apps.
其他Web浏览器的作者将控制当用户长按其应用程序中的图像时发生的情况。
Some Web browser developers might offer a "share image" option when the user long-presses on an image. 当用户长按图像时,某些Web浏览器开发人员可能会提供“共享图像”选项。 For those that do, you can be an option for handling that "share" request by implementing an activity that supports
ACTION_SEND
for whatever MIME types that you support. 对于那些这样做的人,您可以通过实现一个对所支持的MIME类型支持
ACTION_SEND
的活动,来处理“共享”请求。
Some Web browser developers might offer a "save image" or "view image" or "open image in another app" option when the user long-presses on an image. 当用户长按图像时,某些Web浏览器开发人员可能会提供“保存图像”或“查看图像”或“在另一个应用程序中打开图像”选项。 If they do, depending on where and how they do this, it is likely that the user might be able to choose to view the image (eg, once it is "saved").
如果他们这样做,则取决于他们在何处以及如何执行此操作,用户可能能够选择查看图像(例如,一旦“保存”)。 You can be an option for viewing images by implementing an activity that supports
ACTION_VIEW
for whatever MIME types that you support. 您可以通过实现对所支持的MIME类型支持
ACTION_VIEW
的活动来查看图像。
However, please bear in mind that neither of these are exclusive to Web browsers. 但是,请记住,这些都不是Web浏览器专用的。 You will be an option for any matching
ACTION_SEND
or ACTION_VIEW
request, whether it is triggered by a long-press of an image in a Web browser or anything else. 无论是由Web浏览器中的长按图像或其他任何方式触发的,您都可以选择任何匹配的
ACTION_SEND
或ACTION_VIEW
请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.