public void download_WebLink()
{
try
{
Toast.makeText(this, "시작", 5).show();
Log.e("DOWNLOAD", "start");
URL url = new URL("http://xxx.xx.xx.xx/file.dat);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.connect();
Log.e("DOWNLOAD", "Connect");
File SDCardRoot = Environment.getExternalStorageDirectory();
File file = new File(SDCardRoot,"HicomteckMobile.apk");
FileOutputStream fileOutput = new FileOutputStream(file);
Log.e("DOWNLOAD", "fileoutput");
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;
//mProgressBar.setProgress(downloadedSize);
Log.e("DOWNLOAD", "saving...");
pb.setProgress(downloadedSize);
}
fileOutput.close();
} catch (MalformedURLException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
Log.e("DOWNLOAD", "end");
}
위와 같이 했는데요 프로그세스바가 중간단계는 없고 한참잇다가 프로그레스바다 100%가 됩니다
어떻게 해야지 프로그래스바 진행하는걸 보여줄수 있나요?




while루프가 비동기로 처리되지않아서 그렇습니다. while 루프의 루틴을 쓰레드로 동작하게하시고, UI작업(setProgress가 되겠죠?)을 handler로 이동시키시면 될것 같네요.