• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Client-Server
 

Client-Server

on

  • 4,548 views

 

Statistics

Views

Total Views
4,548
Views on SlideShare
0
Embed Views
5,300

Actions

Likes
0
Downloads
120
Comments
0

3 Embeds 5,300

http://androidstream.wordpress.com 2649
http://androidstream.wordpress.com 2649
http://www.linkedin.com 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Client-Server Client-Server Presentation Transcript

    • Android Application Development
      Android and Internet
      Ahsanul Karim
      ahsanul.karim@sentinelbd.com
      Sentinel Solutions Ltd.
      http://www.sentinelbd.com
    • Connecting to the Internet
      Http Connection Example
      In this example we’ll see:
      How to use HttpClient object to send http requests
      How to get response data and show them
      For manipulating HTTP requests/responses in an Android environment, the standard classes
      from the java.net package can be used.
      Thus, classes such as URL, URLConnection, HttpURLConnection etc., can all be used in the
      known way.
    • Connecting to the Internet
      Http Connection Example
      We’ll create a simple project to see HTTP Connection Example
      We create a project with following:
      Project Name: HttpConnectionDemo
      Build Target: 1.6
      Application name:HttpConnectionDemo
      Package name:
      com.basistraining.httpdemo
      Create Activity:
      HttpConnectionDemoActivity
      Min SDK Version: 4
      Add INTERNET permission
    • Connecting to the Internet
      Http Connection Example
      We’ll start with a class named HttpRetriever.
      In this class method: String retrieve (String url) will do the work
    • Connecting to the Internet
      Http Connection Example
      Now from our main Activity, we’ll use this class. To input the url we make a layout
    • Connecting to the Internet
      Http Connection Example
      Now we start with UI components
    • Connecting to the Internet
      Http Connection Example
      On button’s action, we add:
    • Connecting to the Internet
      Http Connection Example
      Now we run
    • Connecting to the Internet
      Http Connection Example
      Now we need to add some checks for internet connection
    • Connecting to the Internet
      How to connect MySQL DB on Web server
      We have:
      a database named httptest
      a table named users with following fields
      Id (integer)
      name (VARCHAR (50))
      email (VARCHAR (50))
      lat (VARCHAR (50))
      long (VARCHAR (50))
      We keep a very simple code in server side- connect to the database- run an SQL query- output it in JSON format
    • Connecting to the Internet
      How to connect MySQL DB on Web server
      As response we get JSON data:
      [
      {“id”:”1”,
      "name":"john",
      "email":"john@a.com",
      "lat":"23.4567",
      "long":"90.86777"},
      {“id”:”2”,
      "name":"smith",
      "email":"smith@b.com",
      "lat":"23.6767",
      "long":"90.986765"}
      ]
    • Connecting to the Internet
      Parsing JSON Data