Android httpclient

910 views

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
910
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Android httpclient

  1. 1. Android Application Development CourseHttpClient and PHP MySQL Mr.Chalermchon Sommana Brightest IDEA
  2. 2. OutlineDay 1●● Get start and setup android tool● Create simple application● Simple connection with PHP MySQL: selectDay 2●● Simple connection with PHP MySQL: select, insert, update, delete● ListView and Custom Adapter
  3. 3. Overview: Connect PHP MySQL Select request Insert response Connect DB MySQL Update Delete
  4. 4. Workshop Output of Connect with PHP Present by ListView
  5. 5. Get Start●Install Android SDK and Eclipse IDE●Install ADT in Eclipse●Create Simple application “Hello Android”●Android File and Folder System●manifest.xml, layout.xml, R.java●Basic UI●Using Android Simulator
  6. 6. Simple Application●Activity●method: OnCreate●method: findViewById
  7. 7. HttpClient (Code)//connectHttpClient httpClient = new DefaultHttpClient();HttpPost httpPost = new HttpPost(url);httpPost.setEntity(new UrlEncodedFormEntity(param));HttpResponse httpRespose = httpClient.execute(httpPost);HttpEntity httpEntity = httpRespose.getEntity();//read contentInputStream in = httpEntity.getContent();BufferedReader read = new BufferedReader(new InputStreamReader(in));String content = "";String line = "";while((line = read.readLine())!=null){ content += line;}
  8. 8. Overview: Post Parameter $w = Key + value $_REQUEST[‘whereId’]param.add(new BasicNameValuePair("whereId", "19")); or $w = $_POST[‘whereId’] Selec NameValuePair Request+parameter Insert C response Update 88
  9. 9. Post Parameter (Code)ArrayList<NameValuePair> param = new ArrayList<NameValuePair>();//test select: whereIdparam.add(new BasicNameValuePair("whereId", "19"));//add parameterhttpPost.setEntity(new UrlEncodedFormEntity(param));
  10. 10. Android Application Development CourseHttpClient and PHP MySQLContact usBrightest IDEA: http://www.brightest-idea.comMr.Chalermchon SommanaBlog: http://adayd3sign.wordpress.comThank you.

×