Views 3448 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 걸렸어요~ 다른걸로 대체하심이 ..

List of Articles
No. Category Subject Author Date Views
170 System/OS [mac] OS X 엘 캐피탄에서 Soudflower 사용하기 2 file hooni 2016.10.03 876
169 System/OS [mac] Mac OS에서 재생되는 사운드를 녹음하는 방법 file hooni 2016.10.03 1440
168 System/OS 맥 OS X 에서 스크린 화면 캡쳐 단축키 (Mac Print Screen) hooni 2015.07.21 1898
167 System/OS [windows] 윈도우 사용자 계정 로그인 암호 분실, 암호 변경하는 방법 file hooni 2015.07.09 21356
166 System/OS 개인적으로 쓰고 있는 bash_profile hooni 2015.01.16 842
165 System/OS [mac][추천 무료앱] 구름 입력기 - 국내 맥 사용자를 위한 한글 대안 입력기 1 file hooni 2015.01.04 2148
164 System/OS [mac] OS X 요세미티 사용자가 많이 겪는 버그와 몇몇 불편사항 file hooni 2015.01.04 1518
163 System/OS [mac] 패키지 매니저, MacPort hooni 2015.01.03 969
162 System/OS [mac] Mac OS 패키지 매니저, HomeBrew file hooni 2015.01.03 1309
161 System/OS [linux] CentOS 에 APM 설치하기 hooni 2015.01.02 1688
160 System/OS CentOS 에서 Cacti 설치하기 hooni 2015.01.02 1762
159 System/OS [svn] 하나의 SVN에서 멀티 저장소 (One svnserve, multiple repositories) hooni 2015.01.02 1549
158 System/OS iptime 공유기 해킹 기술문서 4 file hooni 2015.01.01 1941
157 System/OS [svn] Can't convert string from native encoding to 'UTF-8' 메시지가 나오는 경우 hooni 2014.12.18 993
156 System/OS [svn] SVN trunk 변경사항 되돌리기 (SVN Rollback) hooni 2014.11.27 1564
155 System/OS SVN(Subversion) 설치와 설정 (sasl 인증 적용 포함) file hooni 2014.09.11 5664
Board Pagination Prev 1 2 3 4 5 ... 13 Next
/ 13