[英]How to find the file downloaded by web browser in Android
I am using this code to download a file from my Activity. 我正在使用此代码从我的活动中下载文件。 It downloads the file correctly on emulator and shows the downloading in notification too. 它会在模拟器上正确下载文件,并在通知中也显示下载。 But when i click on notification it just goes off. 但是,当我单击通知时,它就熄灭了。
String url = "http://developer.android.com/shareables/training/ActivityLifecycle.zip";
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri u = Uri.parse(url);
intent.setData(u);
startActivity(intent);
I need to store the path of this downloaded file. 我需要存储此下载文件的路径。
Thanks in advance...:) 提前致谢...:)
I think the locations of files downloaded by web browser is left to web browser discretion (no obligation to publish it). 我认为由网络浏览器下载的文件的位置应由网络浏览器自行决定(无义务发布)。 So I think the best you can do is changing your strategy : 因此,我认为您能做的最好的就是更改策略:
first download the file. 首先下载文件。 This question explain how to do it : Download a file with Android, and showing the progress in a ProgressDialog 这个问题解释了如何做到这一点: 使用Android下载文件,并在ProgressDialog中显示进度
then launch your ACTION_VIEW intent, but pass the uri of the just downloaded file instead of the external url 然后启动您的ACTION_VIEW意向,但传递刚刚下载的文件的uri而不是外部网址
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.