마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

프로그레스바 진행시 dofileupload

0 추천
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에서 멈추네요 어덯게 해결하나요 ㅠㅠ

안드로이드찢어 (1,080 포인트) 님이 2015년 4월 15일 질문
안드로이드찢어님이 2015년 4월 15일 수정
뭘 하고 싶다는 건지 이해가 안되네요.

질문자 님이 다시 한번 천천히 읽어보세요. 다른 사람이 봤을 때 이해가 될것 같은지.

>그래서 버튼을 누르면 dofileupload 가 되고 파일이 업로드되는동안 프로그레스바도 진행되는걸 보여>>주고싶은데요 그게 안되네요.

>아니면 프로그레스바를 돌리면서 dofileupload 를 하면 count 가 15일떄 제가 dofileupload 를 하는데

>프로그레스바가 15에서 멈추네요 어덯게 해결하나요 ㅠㅠ
파일업로드할때 프로그레스바안멈추고 계속 진행하고싶어요

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...