在我的应用程序中,我希望将progressDialog实现到图像下载过程中,在此之后,我想调用意图ACTION_ATTACH_DATA。目前,我的代码工作良好,但正如您所看到的,当它开始下载时,立即称为意图。我的目标是显示下载后的意图,并使用一个进度对话框。(谢谢你的帮助:)
代码:
Button impostacome = (Button)popupView2.findViewById(R.id.impostacome);
impostacome.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
File folder = new File(Environment.getExternalStorageDirectory() + "/Wallpaper");
boolean success = false;
if (!folder.exists()) {
success = folder.mkdirs();
}
if (!success) {
} else {
}
File direct = new File("/sdcard/Wallpaper/");
if (!direct.exists()) {
direct.mkdirs();
}
DownloadManager mgr = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
Uri downloadUri = Uri.parse("http://www.brothersapp.com/immaginiapp/wallpaper/1");
DownloadManager.Request request = new DownloadManager.Request(
downloadUri);
request.setAllowedNetworkTypes(
DownloadManager.Request.NETWORK_WIFI
| DownloadManager.Request.NETWORK_MOBILE)
.setAllowedOverRoaming(false).setTitle("brothersapp download")
.setDescription("The image is Downloading...")
.setDestinationInExternalPublicDir("/brothersapp/", "/1.jpg/");
mgr.enqueue(request);
Intent myintent = new Intent(Intent.ACTION_ATTACH_DATA);
Uri sendUri = Uri.parse("file:///sdcard/brothersapp/1.jpg");
myintent.setDataAndType(sendUri, "image/*");
startActivity(Intent.createChooser(myintent, "Set As"));发布于 2014-02-13 17:04:13
DownloadManager异步工作。您的代码不会等待下载完成。如果要在下载文件时执行某些操作,则需要收听ACTION_DOWNLOAD_COMPLETE广播。
PS:你没有表现出意图。
https://stackoverflow.com/questions/21760658
复制相似问题