Contents

조회 수 3631 댓글 1
Atachment
첨부 '1'
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

라이브러리 안 쓰고 간단한 POST 전송하는 예제

public void postData() {
    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://www.hooni.net/ip.php");

    try {
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("id", "hooni"));
        nameValuePairs.add(new BasicNameValuePair("passwd", "ok!"));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
    } catch (IOException e) {
        // TODO Auto-generated catch block
    }
}

[출처] http://stackoverflow.com/questions/2938502/sending-post-data-in-android


?
  • ?
    ㄴㄴ 2017.05.04 17:02
    NameValuePair는 안드로이드 스튜디오에서는 Deplicate 걸렸어요~ 다른걸로 대체하심이 ..

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
285 Develop [c++] WinSock2.0 채팅 프로그램 ㅋㅋ file hooni 2013.04.23 8563
284 Develop [c] 무선 Radius Server 자료.. file hooni 2013.04.23 7283
283 Develop [c++] MD5 구현 소스.. 퍼움.. file hooni 2013.04.23 24137
282 Develop [c] 콘솔에서 패스워드 입력시 문자 보이지 않게 하는 코드 file hooni 2013.04.23 8359
281 Develop [c] 도스 공격(DoS Attack) 프로그램 file hooni 2013.04.23 11597
280 Develop [php] 웹 터미널 & 업로드 소스.. file hooni 2013.04.23 7255
279 Develop [c] 간단한 점 이동 샘플 소스코드 hooni 2013.04.23 6580
278 System/OS 해커스랩 깨기.. 후후.. ㅋㅋ file hooni 2013.04.23 18520
277 Develop [php] 웹 응용프로그램(engines) 모음 file hooni 2013.04.23 7563
276 Develop [js] One Time Pad key generatorㅡ.,ㅡ; file hooni 2013.04.23 6812
275 Algorithm 암호 알고리즘 및 프로토콜의 이해.. file hooni 2013.04.23 17260
274 System/OS [linux] /etc/fstab 설정 방법.. ㅋㅋ hooni 2013.04.23 12150
Board Pagination Prev 1 ... 70 71 72 73 74 75 76 77 78 79 ... 98 Next
/ 98