Contents

조회 수 3445 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
22 System/OS [windows] 종료, 재시작, 로그아웃 아이콘 만들기 hooni 2013.04.23 18102
21 System/OS [windows] 최근 열어본 문서목록 안나오게 하는 방법 hooni 2013.04.23 25475
20 System/OS [windows] 패스워드를 잊어먹었을때.. hooni 2003.04.23 17294
19 System/OS [펌] 마이크로서비스, 모노리포, SRE, ... 덮어놓고 구글 따라하면 안 되는 기술들 file hooni 2020.10.15 939
18 System/OS 개인적으로 쓰고 있는 bash_profile hooni 2015.01.16 840
17 System/OS 개인적으로 쓰고 있는 zshrc 파일 hooni 2022.02.25 822
16 System/OS 나중에 해봐야지.. libconv 설치.. ㅡ,.ㅡ; hooni 2013.04.23 19284
15 System/OS 네트워크 용어 정리 file hooni 2022.11.20 1185
14 System/OS 네트워크별 MTU(최대 전송 단위) hooni 2013.04.23 17641
13 System/OS 라우팅 경로 결정 영향 요소 ㅋㅋ file hooni 2013.04.23 15850
12 System/OS 맥 OS X 에서 스크린 화면 캡쳐 단축키 (Mac Print Screen) hooni 2015.07.21 1896
11 System/OS 맥북에서 MAC/윈도우 멀티부팅시 시간 설정 file hooni 2013.04.23 29757
Board Pagination Prev 1 ... 8 9 10 11 12 13 14 15 16 17 Next
/ 17