简体   繁体   中英

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

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. You might be able to pull this off if your app is running as 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 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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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