简体   繁体   English

当任何浏览器在android上保存文件时,是否发送了广播? 如何在Android的浏览器中拦截保存/下载的文件?

[英]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: 我想在电话上看到的确切内容:

  • Users holds finger down on image in the browser 用户将手指放在浏览器中的图像上
  • User chooses to download (or some other choice as created by my application) 用户选择下载(或由我的应用程序创建的其他选择)
  • My application is presented as a destination or handler for this content, as when I attempt to take a photo it will ask me if I would like to use Camera or Snapchat. 我的应用程序将作为此内容的目的地处理程序出现 ,因为当我尝试拍照时,它将询问我是否要使用Camera或Snapchat。 I assume this would be done by handling the intent. 我认为这将通过处理意图来完成。

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_SENDACTION_VIEW请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何阻止webChromeClient在Android浏览器中打开文件 - How can I stop webChromeClient from opening files in the Android Browser Android:如何更改下载文件的文件名? - Android: How do I change the file name of downloaded files? 我可以使用Selenium在浏览器堆栈中验证下载的文件吗 - Can i verify downloaded file in browser stack using selenium 如何验证文件已在android中完全下载? - How can I verify that a file was completely downloaded in android? Firebase存储Android:如何更改下载文件的文件名? - Firebase Storage Android: How can I change the the filename of a downloaded file? 当我访问某个URL时,如何下载在网络浏览器中自动下载的文件? - How to download a file that is automatically downloaded in a web browser when I visit a certain URL? 如何验证从 selenium 节点系统上运行的 chrome 浏览器下载的文件 - how can I verify a file downloaded from chrome browser running on selenium node system 当我在应用浏览器中的android webview中打开链接时,如何在左上方放置关闭按钮 - when i open a link in android webview in app browser how can i put close button on top left 如何在Windows平台上显示android文件浏览器 - how to show android file browser in windows platform 拦截发送短信android - Intercept Sent text messages android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM