android httpclient - new slide!

10
Android Application Development Course HttpClient and PHP MySQL Mr.Chalermchon Sommana Brightest IDEA

Upload: chalermchon-sommana

Post on 15-Jan-2015

1.305 views

Category:

Documents


2 download

DESCRIPTION

Android HttpClient and PHP MySQL see more android/iOS application Development : http://adayd3sign.wordpress.com/ join me : http://www.brightest-idea.com

TRANSCRIPT

Page 1: Android HttpClient - new slide!

Android Application Development Course

HttpClient and PHPMySQL

Mr.Chalermchon SommanaBrightest IDEA

Page 2: Android HttpClient - new slide!

Outline

●Day 1● Get start and setup android tool● Create simple application● Simple connection with PHP MySQL: select

●Day 2● Simple connection with PHP MySQL: select,insert, update, delete

● ListView and Custom Adapter

Page 3: Android HttpClient - new slide!

Overview: Connect PHP MySQL

MySQL

Delete

Update

Insert

Selectrequest

response Connect DB

Page 4: Android HttpClient - new slide!

Workshop

Output of Connect with PHP Present by ListView

Page 5: Android HttpClient - new slide!

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

Page 6: Android HttpClient - new slide!

Simple Application

●Activity●method: OnCreate●method: findViewById

Page 7: Android HttpClient - new slide!

HttpClient (Code)

//connect HttpClient 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;}

Page 8: Android HttpClient - new slide!

Overview: Post Parameter

88

MySQLUpdate

Insert

Select

Request+parameter

response Connect DB

NameValuePair

Key + value param.add(new BasicNameValuePair("whereId", "19"));

$w = $_REQUEST[‘whereId’]

or$w = $_POST[‘whereId’]

Page 9: Android HttpClient - new slide!

Post Parameter (Code)

ArrayList<NameValuePair> param = new ArrayList<NameValuePair>();

//test select: whereId param.add(new BasicNameValuePair("whereId", "19"));

//add parameterhttpPost.setEntity(new UrlEncodedFormEntity(param));

Page 10: Android HttpClient - new slide!

Android Application Development Course

HttpClient and PHPMySQL

Contact usBrightest IDEA: http://www.brightest-idea.com

Mr.Chalermchon SommanaBlog: http://adayd3sign.wordpress.comThank you.