0
在我的應用程序我很想實現一個progressDialog的圖像下載過程,在此之後,我想調用intent ACTION_ATTACH_DATA。目前我的代碼工作正常,但正如你可以看到它開始下載時,立即稱爲意圖。我的目標是在下載後顯示意圖並使用progressdialog。感謝您的幫助:)ProgressDialog DownloadManager
代碼:
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"));
謝謝我如何讓下載管理器與進度條一起工作? 也許我可以使下載開始時顯示progressdialog,並在下載完成後將其刪除? –
你爲什麼想這樣做? DownloadManager有自己的進度條,所以我個人認爲沒有重複該功能的重點 –