简体   繁体   English

如何创建一个可检测设备所有下载内容的Android应用?

[英]How to create an android app that detects all of the device's download?

I need to create an android application that does some work with any file that the device downloads. 我需要创建一个Android应用程序,该设备可以对设备下载的任何文件进行一些处理。 The problem is that I don't know how to notify my application whenever a download is initiated on the device. 问题是,无论何时在设备上启动下载,我都不知道如何通知我的应用程序。 I need some way so that either all of the device's downloads are done through my app, or my app gets notified whenever a file is downloaded by the device. 我需要某种方式,以便设备的所有下载都通过我的应用程序完成,或者只要设备下载了文件,我的应用程序就会收到通知。 I want to make clear here that I don't want to detect when my application is downloading something, I need to detect each download that the device makes so I can work on the newly downloaded file. 我想在此说明,我不想检测我的应用程序何时下载东西,我需要检测设备进行的每次下载,以便可以处理新下载的文件。

I need to create an android application that does some work with any file that the device downloads. 我需要创建一个Android应用程序,该设备可以对设备下载的任何文件进行一些处理。

That is not possible for a normal SDK application, as there is no requirement that every app that downloads a file put the file in a place where you can get at it. 对于普通的SDK应用程序来说这是不可能的,因为没有要求每个下载文件的应用程序都将文件放置在可以获取的位置。 You might be able to pull this off if your app is running as root. 如果您的应用程序以root身份运行,则可能可以实现此目的。

The problem is that I don't know how to notify my application whenever a download is initiated on the device. 问题是,无论何时在设备上启动下载,我都不知道如何通知我的应用程序。

That is not possible, as there is no definition of "download is initiated". 这是不可能的,因为没有“启动下载”的定义。 Not all Internet traffic represents a downloaded file. 并非所有的Internet通信都代表下载的文件。 Internet traffic represents a downloaded file if and only if the app that used the Internet writes a file that directly represents the bytes received from the Internet. 当且仅当使用Internet的应用程序编写的文件直接表示从Internet接收的字节时,Internet流量才表示下载的文件。 This will be exceptionally difficult to distinguish, as plenty of things (eg, updating a database) would also involve Internet I/O followed by disk I/O. 这将很难区分,因为很多事情(例如,更新数据库)也将涉及Internet I / O,然后是磁盘I / O。

I need some way so that either all of the device's downloads are done through my app 我需要某种方式,以便通过我的应用程序完成设备的所有下载

That is not possible, except perhaps on a rooted device if you tinker with firewall settings. 这是不可能的,但如果您修改防火墙设置,则可能是在有根设备上进行。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM