简体   繁体   English

如何检测在Android中下载的文件

[英]How to detect File downloaded in android

Is their a way to detect file is downloaded, any broadcast receiver, file observer, content observer or any other method & get its path. 是他们检测文件下载的方法,任何广播接收器,文件查看器,内容查看器或任何其他方法并获取其路径。 I have google it but didn't find any luck. 我有谷歌它,但没有发现任何运气。 Looking forward for your experience advice. 期待您的经验咨询。

Note : I can detect new files from camera using File Observer, so I know how to use above mention methods. 注意:我可以使用“文件观察器”从相机检测新文件,因此我知道如何使用上述方法。

Edit: File downloaded from any app, lets say hotmail or dropbox, observe it from background service.. 编辑:从任何应用程序下载的文件,比如说hotmail或保管箱,从后台服务观察它。

I would suggest you to make file downloading code in The asynctask and Observer. 我建议您在asynctask和Observer中进行文件下载代码。

onPostExecute method of asyctask Update the flag variable to be download status and then use it in the main thread from where it is called in Update Method of Observer. asyctask的onPostExecute方法将flag变量更新为下载状态,然后在Observer的Update Method中从其调用的主线程中使用它。

new Observer() { 新的Observer(){

        @Override
        public void update(Observable observable, Object data) {
           // From here you can parse your response and take appropriate action.

        }
    };

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

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