Android with DownloadManager get total file size -
i have researched every no solution. have snippet code run , total file size while in debug mode of eclipse. when run project value of sizeofdownloadingfile return -1. please me, compile android 22, in advance.
long id = downloadmanager.enqueue(request); cursor cursor = downloadmanager.query(new downloadmanager.query() .setfilterbyid(id)); if (!cursor.movetofirst()) { log.v("downloadmanagerservice", "download list empty"); return; } int sizeofdownloadingfile = 0; sizeofdownloadingfile = cursor.getint(cursor .getcolumnindex(downloadmanager.column_total_size_bytes)); log.d("downloadmanagerservice", "file size of film " + mfilm.getmtitle() + " " + sizeofdownloadingfile);
if call code in main thread try:
new handler().postdelayed(new runnable() { @override public void run() { check here size of downloading file } },500);
when in debug mode downloader propably start download , have valid value, if ran app normaly downloader have connect server , doanload file, take more time execution of code.
Comments
Post a Comment