지금 파일다운받는거 프로그레스로 표현하고있는데요
문제점은
1/100까지 %단위로 구현하고있습니다..
그런데 맨처음에 1%로 시작하여 올라가지않고 파일다운로드가 완료가 되어야지 1%가 올라가게됩니다.ㅠㅠ
고로 100%까지 차려면 100번을 다운받아야한다는소린데... 감이 오질않네요
조언좀 해주세요
package jane.paker;
import java.io.*;
import java.net.*;
import android.app.*;
import android.content.*;
import android.os.*;
import android.view.*;
import android.widget.*;
public class Web extends Activity {
int mValue;
ProgressDialog mProgress;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.network_downhtml);
Button btn = (Button)findViewById(R.id.down);
btn.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
new AccumulateTask().execute(100);
}
});
}
class AccumulateTask extends AsyncTask<Integer, Integer, Integer> {
protected void onPreExecute() {
mValue = 0;
mProgress = new ProgressDialog(Web.this);
mProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgress.setTitle("DownLoading");
mProgress.setMessage("Wait...");
mProgress.setCancelable(false);
mProgress.setProgress(0);
mProgress.setButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
cancel(true);
}
});
mProgress.show();
}
protected Integer doInBackground(Integer... arg0) {
while (isCancelled() == false) {
mValue++;
if (mValue <= 100) {
publishProgress(mValue);
} else {
break;
}
try {
URL url = new URL("url비공개");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setDoOutput(true);
urlConnection.connect();
File SDCardRoot = Environment.getExternalStorageDirectory();
File file = new File(SDCardRoot, "compass123.zip");
FileOutputStream fileOutput = new FileOutputStream(file);
InputStream inputStream = urlConnection.getInputStream();
int totalSize = urlConnection.getContentLength();
int downloadedSize = 0;
byte[] buffer = new byte[1024];
int bufferLength = 0;
while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
fileOutput.write(buffer, 0, bufferLength);
downloadedSize += bufferLength;
updateProgress(downloadedSize, totalSize);
}
fileOutput.close();
// } catch (MalformedURLException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return mValue;
}
protected void onProgressUpdate(Integer... progress) {
mProgress.setProgress(progress[0]);
}
protected void onPostExecute(Integer result) {
mProgress.dismiss();
}
protected void onCancelled() {
mProgress.dismiss();
}
}
public void updateProgress(int downloadedSize, int totalSize) {
// TODO Auto-generated method stub
}
}




// TODO Auto-generated method stub
}