System/OS
2017.02.16 16:15
[android] 초간단 HTTP, POST 전송 샘플
Views 6494 Comment 1
Attachment '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
-
?
NameValuePair는 안드로이드 스튜디오에서는 Deplicate 걸렸어요~ 다른걸로 대체하심이 ..
No. | Category | Subject | Author | Date | Views |
---|---|---|---|---|---|
168 | System/OS | [switch] 시스코 스위치 관리자 암호 초기화 방법 | hooni | 2013.04.23 | 18030 |
167 | System/OS | [svn] 하나의 SVN에서 멀티 저장소 (One svnserve, multiple repositories) | hooni | 2015.01.02 | 2636 |
166 | System/OS | [svn] SVN trunk 변경사항 되돌리기 (SVN Rollback) | hooni | 2014.11.27 | 2617 |
165 | System/OS | [svn] Can't convert string from native encoding to 'UTF-8' 메시지가 나오는 경우 | hooni | 2014.12.18 | 2206 |
164 | System/OS | [sql] 중복데이터 삭제 쿼리 | hooni | 2013.04.23 | 15767 |
163 | System/OS | [sql] 조회구문(select)에서 중복 데이터를 한 번만 출력 (distinct) 1 | hooni | 2013.04.23 | 35652 |
162 | System/OS | [sql] 내 방명록 답글 찾는 쿼리문.. (JOIN 구문) | hooni | 2003.04.23 | 13777 |
161 | System/OS | [sql] insert into select 사용하기 | hooni | 2013.04.23 | 31878 |
160 | System/OS | [sql] alter table 쿼리 예제 | hooni | 2003.04.23 | 13318 |
159 | System/OS | [router] 시스코 라우터 명령어 모드.. | hooni | 2013.04.23 | 13677 |
158 | System/OS | [router] 설정과 기본 명령어들 모음 | hooni | 2013.04.23 | 16453 |
157 | System/OS | [router] 라우팅 프로토콜 BGP (간단한 세팅) | hooni | 2013.04.23 | 11648 |