System/OS
2017.02.16 16:15
[android] 초간단 HTTP, POST 전송 샘플
Views 6468 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 |
---|---|---|---|---|---|
204 | System/OS | 개인적으로 쓰고 있는 bash_profile | hooni | 2015.01.16 | 1999 |
203 | System/OS | [mac] 패키지 매니저, MacPort | hooni | 2015.01.03 | 2136 |
202 | System/OS | [svn] Can't convert string from native encoding to 'UTF-8' 메시지가 나오는 경우 | hooni | 2014.12.18 | 2195 |
201 | System/OS | [linux] yum 업데이트 시 커널 제외하기 | hooni | 2014.09.11 | 2313 |
200 | System/OS |
[mac] Mac OS 패키지 매니저, HomeBrew
![]() |
hooni | 2015.01.03 | 2545 |
199 | System/OS | [svn] SVN trunk 변경사항 되돌리기 (SVN Rollback) | hooni | 2014.11.27 | 2605 |
198 | System/OS | [svn] 하나의 SVN에서 멀티 저장소 (One svnserve, multiple repositories) | hooni | 2015.01.02 | 2623 |
197 | System/OS | [mac] How to uninstall MySQL on Mac OS. | hooni | 2017.11.08 | 2629 |
196 | System/OS |
[virtualbox] VirtualBox에 Ubuntu 설치하기
![]() |
hooni | 2019.11.22 | 2640 |
195 | System/OS | [mac] Homebrew/rvm/cocoapod setting | hooni | 2017.07.29 | 2644 |
194 | System/OS | [linux] iptables 초간단 세팅 스크립트 | hooni | 2017.09.26 | 2693 |
193 | System/OS | [linux] CentOS 에 APM 설치하기 | hooni | 2015.01.02 | 2974 |