Views 6473 Votes 0 Comment 1
Atachment
Attachment '1'
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

라이브러리 안 쓰고 간단한 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. [linux] 데비안(debian.org) 리눅스 명령어 예제

  2. [unix] AIX쉘 초기 파일 (.cshrc)

  3. [linux] man 명령어 뽀개기..

  4. [linux] 간단한 find 명령어 설명(업데이트 해야 함)

  5. HTTPS와 SSL 인증서

  6. Enable Safari Hidden Debug Menu in Mac OS X

  7. [windows] 윈도우즈 콘솔에서 정품인증 하는 방법

  8. [linux] CentOS 6.5 에서 "Bringing up interface eth0: Determining if ip address 121.78.127.197 is already in use for device eth0..."

  9. SVN(Subversion) 설치와 설정 (sasl 인증 적용 포함)

  10. 맥에서 포트 확인하고 닫기 (mac)

  11. Brave Browser for Debian, Ubuntu, Mint

  12. [android] 초간단 HTTP, POST 전송 샘플

  13. [mac] Mac OS에서 재생되는 사운드를 녹음하는 방법

  14. Apache CORS 설정

  15. [linux] 초간단 SquirrelMail 설치/설정 (다람쥐 메일)

  16. [mac] 맥(OSX)에서 NTFS, 윈도우에서 HFS+ 사용하기

Board Pagination Prev 1 ... 8 9 10 11 12 13 Next
/ 13