Contents

조회 수 3482 댓글 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 걸렸어요~ 다른걸로 대체하심이 ..

  1. [ios] FlckrFeed Example App (Swift)

    Date2016.11.27 CategoryDevelop Byhooni Views1079
    Read More
  2. [android] 버전 별 앱 알림 설정으로 이동하는 방법

    Date2016.11.28 CategoryDevelop Byhooni Views2164
    Read More
  3. 웹 보안 논문 주제 2016

    Date2016.11.28 CategoryEtc Byhooni Views0
    Read More
  4. [ppt] 정보보호관리 발표내용

    Date2016.11.30 CategoryPPT Byhooni Views1082
    Read More
  5. ISMS 인증기준 – 정보보호대책 (시스템개발보안)

    Date2016.12.01 CategoryEtc Byhooni Views1328
    Read More
  6. [ppt] 정보보호관리 발표내용 #2

    Date2016.12.08 CategoryPPT Byhooni Views1071
    Read More
  7. XML, JSON, BSON, MSGPACK 장,단점 비교

    Date2017.01.11 CategoryDevelop Byhooni Views2246
    Read More
  8. [ios] 동영상 플레이어 샘플 (for Local File)

    Date2017.02.07 CategoryDevelop Byhooni Views1077
    Read More
  9. [ios] 동영상 플레이어 샘플 (for Remote Url)

    Date2017.02.07 CategoryDevelop Byhooni Views1648
    Read More
  10. Enable the Develop Menu in Safari

    Date2017.02.07 CategorySystem/OS Byhooni Views1079
    Read More
  11. Enable Safari Hidden Debug Menu in Mac OS X

    Date2017.02.07 CategorySystem/OS Byhooni Views1153
    Read More
  12. [android] 초간단 HTTP, POST 전송 샘플

    Date2017.02.16 CategorySystem/OS Byhooni Views3482
    Read More
Board Pagination Prev 1 ... 83 84 85 86 87 88 89 90 91 92 ... 98 Next
/ 98