System/OS
2017.02.16 16:15
[android] 초간단 HTTP, POST 전송 샘플
조회 수 3485 댓글 1
첨부 '1' |
|
---|
라이브러리 안 쓰고 간단한 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
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
46 | System/OS | [router] 시스코 라우터 명령어 모드.. | hooni | 2013.04.23 | 12948 |
45 | System/OS | [sql] alter table 쿼리 예제 | hooni | 2003.04.23 | 12459 |
44 | System/OS | [sql] insert into select 사용하기 | hooni | 2013.04.23 | 27556 |
43 | System/OS | [sql] 내 방명록 답글 찾는 쿼리문.. (JOIN 구문) | hooni | 2003.04.23 | 12845 |
42 | System/OS | [sql] 조회구문(select)에서 중복 데이터를 한 번만 출력 (distinct) 1 | hooni | 2013.04.23 | 33941 |
41 | System/OS | [sql] 중복데이터 삭제 쿼리 | hooni | 2013.04.23 | 14737 |
40 | System/OS | [svn] Can't convert string from native encoding to 'UTF-8' 메시지가 나오는 경우 | hooni | 2014.12.18 | 993 |
39 | System/OS | [svn] SVN trunk 변경사항 되돌리기 (SVN Rollback) | hooni | 2014.11.27 | 1565 |
38 | System/OS | [svn] 하나의 SVN에서 멀티 저장소 (One svnserve, multiple repositories) | hooni | 2015.01.02 | 1549 |
37 | System/OS | [switch] 시스코 스위치 관리자 암호 초기화 방법 | hooni | 2013.04.23 | 17188 |
36 | System/OS | [switch] 시스코 카탈리스트(Cisco Catalyst) 기본 설정 | hooni | 2013.04.23 | 17497 |
35 | System/OS | [unix] AIX쉘 초기 파일 (.cshrc) | hooni | 2013.04.23 | 10293 |