go.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
kk = getListView().getItemAtPosition(position).toString();
String[] jpg = kk.split("/");
String mvv = jpg[jpg.length - 1];
mv = mvv.split("\\.")[0];
showDialog(1);
count = 0;
progressDialog.setProgress(0);
handler.sendEmptyMessage(0);
}
});
return row;
}
}
///
private void doFileUpload() {
HttpURLConnection conn = null;
DataOutputStream dos = null;
DataInputStream inStream = null;
String lineEnd = "\r\n";
String twoHyphens = "--";
String boundary = "*****";
String urlString = "test.asp";
try {
// ------------------ CLIENT REQUEST
// open a URL connection to the Servlet
URL url = new URL(urlString);
// Open a HTTP connection to the URL
conn = (HttpURLConnection) url.openConnection();
// Allow Inputs
conn.setDoInput(true);
// Allow Outputs
conn.setDoOutput(true);
// Don't use a cached copy.
conn.setUseCaches(false);
// Use a post method.
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("Content-Type",
"multipart/form-data;boundary=" + boundary);
dos = new DataOutputStream(conn.getOutputStream());
for (int i = 0; i < 1; i++) {
dos.writeBytes(twoHyphens + boundary + lineEnd);
dos.writeBytes("Content-Disposition: form-data; name=\""
+ "tag" + "\"" + lineEnd);
dos.writeBytes(lineEnd);
dos.writeBytes("action");
dos.writeBytes(lineEnd);
dos.writeBytes(twoHyphens + boundary + lineEnd);
dos.writeBytes("Content-Disposition: form-data; name=\"" + "id"
+ "\"" + lineEnd);
dos.writeBytes(lineEnd);
dos.writeBytes(dkdlel);
dos.writeBytes(lineEnd);
dos.writeBytes(twoHyphens + boundary + lineEnd);
dos.writeBytes("Content-Disposition: form-data; name=\"" + "pw"
+ "\"" + lineEnd);
dos.writeBytes(lineEnd);
dos.writeBytes(qlqjs);
dos.writeBytes(lineEnd);
dos.writeBytes(twoHyphens + boundary + lineEnd);
dos.writeBytes("Content-Disposition: form-data; name=\""
+ "movie_name" + "\"" + lineEnd);
dos.writeBytes(lineEnd);
dos.writeBytes(mv);
dos.writeBytes(lineEnd);
}
// create a buffer of maximum size
// read file and write it into form...
// send multipart form data necesssary after file data...
dos.writeBytes(lineEnd);
dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
// close streams
Log.e("Debug1", "File is written");
dos.flush();
dos.close();
} catch (MalformedURLException ex) {
Log.e("Debug2", "error: " + ex.getMessage(), ex);
} catch (IOException ioe) {
Log.e("Debug3", "error: " + ioe.getMessage(), ioe);
}
StringBuilder builder = new StringBuilder();
// ------------------ read the SERVER RESPONSE
try {
inStream = new DataInputStream(conn.getInputStream());
String str;
while ((str = inStream.readLine()) != null) {
builder.append(str); // View에 표시하기 위해 라인 구분자 추가
composeok = builder.toString();
Log.i("LSJ", "========== [서버에서 받음 BMP OK] ========== "
+ composeok);
}
inStream.close();
} catch (IOException ioex) {
Log.e("Debug5", "error: " + ioex.getMessage(), ioex);
}
}
}
// 헨들러
handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 0:
if (count <= 100) {
count++;
progressDialog.incrementProgressBy(1);
handler.sendEmptyMessageDelayed(0, 1000);
if (count == 15) {
// HttpPostData();
doFileUpload();
}
if (count == 100 && composeok.equals("OK")) {
progressDialog.dismiss();
Toast.makeText(getBaseContext(), "합성이 완료 되었습니다.",
Toast.LENGTH_SHORT).show();
Intent i = new Intent(Video.this, Down.class);
i.putExtra("id", dkdlel);
i.putExtra("pw", qlqjs);
startActivity(i);
Log.i("LSJ",
"======= [sent down activity] id======= :"
+ dkdlel);
Log.i("LSJ",
"======= [sent down activity] pw====== :"
+ qlqjs);
}
}
}
}
};
현재 상황
프로그레스바 퍼센트가 15% 일때 dofileupload 를 하여 파일을 업로드합니다 . 그런데 프로그레스바는 계속 돌다가 14% 가 되면 진행되는게 멈추게됩니다. 이걸 안멈추고 계속 진행되게하는방법 있을까요?
프로그레스바가 15에서 멈추네요 어덯게 해결하나요 ㅠㅠ