1
私はAndroidアプリケーションでダウンロードする時間を得なければならないので、ダウンロードの開始日と終了日を決定する必要があります。 私は最初とdoInBackground
の最後にこれらの行を追加しました:ダウンロードの開始時刻と終了時刻を取得する
Log.v("Download_INFO","i begin downloading at : "+" "+dt.getHours()+"h "+dt.getMinutes()+"min "
+dt.getSeconds()+"sec");
Log.v("Download_INFO","i complete downloading at : "+" "+dt.getHours()+"h "+dt.getMinutes()
+"min "+dt.getSeconds()+"sec");
しかし、驚きは、私はいくつかの時間を持っていたということです。
protected String doInBackground(String... aurl) {
int count;
try {
File vSDCard = null;
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
vSDCard = Environment.getExternalStorageDirectory();
File vFile = new File(vSDCard.getParent() + "/" + vSDCard.getName() + "/"
+ "downloadTest.jpg");
URL url = new URL(aurl[0]);
URLConnection conexion = url.openConnection();
conexion.connect();
int lenghtOfFile = conexion.getContentLength();
Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(vFile);
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
publishProgress("" + (int) ((total * 100)/lenghtOfFile));
output.write(data, 0, count);
}
Log.v("Download_INFO","i complete downloading at : "+" "+dt.getHours()+"h "+dt.getMinutes()
+"min "+dt.getSeconds()+"sec");
output.flush();
output.close();
input.close();
System.out.println(currentDateTimeString);
}
} catch (Exception e) {
Log.d("ImageManager", "Error: " + e);
}
return null;
}
問題は何をしてくださいます。私は、これは私のdoInBackground
方法である理由に
を理解することはできません!
素晴らしいと思います。それはちょうど "System.currentTimeMillis" – Linconnue55