SlideShare une entreprise Scribd logo
1  sur  12
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

Contenu connexe

Tendances

Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
KingsleyUsen_SRS_Gmail
KingsleyUsen_SRS_GmailKingsleyUsen_SRS_Gmail
KingsleyUsen_SRS_Gmail
Kingsley Usen
 
Android Service Intro
Android Service IntroAndroid Service Intro
Android Service Intro
Jintin Lin
 
Login and private message
Login and private messageLogin and private message
Login and private message
gueste832a8e
 
Best crm my salesdilaer
Best crm my salesdilaerBest crm my salesdilaer
Best crm my salesdilaer
Vikas Mahore
 

Tendances (20)

Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 
Develop a native application that uses GPS location.pptx
Develop a native application that uses GPS location.pptxDevelop a native application that uses GPS location.pptx
Develop a native application that uses GPS location.pptx
 
Android Application that makes use of RSS Feed.pptx
Android Application that makes use of RSS Feed.pptxAndroid Application that makes use of RSS Feed.pptx
Android Application that makes use of RSS Feed.pptx
 
Building a YellowAnt Application with Ruby on Rails
Building a YellowAnt Application with Ruby on RailsBuilding a YellowAnt Application with Ruby on Rails
Building a YellowAnt Application with Ruby on Rails
 
Building a YellowAnt application with .NET
Building a YellowAnt application with .NETBuilding a YellowAnt application with .NET
Building a YellowAnt application with .NET
 
Android Service
Android ServiceAndroid Service
Android Service
 
KingsleyUsen_SRS_Gmail
KingsleyUsen_SRS_GmailKingsleyUsen_SRS_Gmail
KingsleyUsen_SRS_Gmail
 
Android Service Intro
Android Service IntroAndroid Service Intro
Android Service Intro
 
Login and private message
Login and private messageLogin and private message
Login and private message
 
Murach: How to transfer data from controllers
Murach: How to transfer data from controllersMurach: How to transfer data from controllers
Murach: How to transfer data from controllers
 
Murach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVCMurach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVC
 
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
 
Mailing, the developer's eye view
Mailing, the developer's eye viewMailing, the developer's eye view
Mailing, the developer's eye view
 
Murach : How to work with session state and cookies
Murach : How to work with session state and cookiesMurach : How to work with session state and cookies
Murach : How to work with session state and cookies
 
Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web
 
Request and response json
Request and response jsonRequest and response json
Request and response json
 
Murach : HOW to work with controllers and routing
Murach : HOW to work with controllers and routingMurach : HOW to work with controllers and routing
Murach : HOW to work with controllers and routing
 
Murach: How to use Entity Framework EF Core
Murach: How to use Entity Framework EF  CoreMurach: How to use Entity Framework EF  Core
Murach: How to use Entity Framework EF Core
 
Best crm my salesdilaer
Best crm my salesdilaerBest crm my salesdilaer
Best crm my salesdilaer
 
Facebook Login & Open Graph Introduction
Facebook Login & Open Graph IntroductionFacebook Login & Open Graph Introduction
Facebook Login & Open Graph Introduction
 

En vedette

Android before getting started
Android before getting startedAndroid before getting started
Android before getting started
Ahsanul Karim
 
Lecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting StartedLecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting Started
Ahsanul Karim
 
Ui layout (incomplete)
Ui layout (incomplete)Ui layout (incomplete)
Ui layout (incomplete)
Ahsanul Karim
 
Lecture 3 getting active through activities
Lecture 3 getting active through activities Lecture 3 getting active through activities
Lecture 3 getting active through activities
Ahsanul Karim
 
Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in Background
Ahsanul Karim
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
Ahsanul Karim
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application Development
Ahsanul Karim
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
Ahsanul Karim
 

En vedette (17)

Android before getting started
Android before getting startedAndroid before getting started
Android before getting started
 
Lecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting StartedLecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting Started
 
AndroidManifest
AndroidManifestAndroidManifest
AndroidManifest
 
Ui layout (incomplete)
Ui layout (incomplete)Ui layout (incomplete)
Ui layout (incomplete)
 
Lecture 3 getting active through activities
Lecture 3 getting active through activities Lecture 3 getting active through activities
Lecture 3 getting active through activities
 
Day1 before getting_started
Day1 before getting_startedDay1 before getting_started
Day1 before getting_started
 
GCM for Android
GCM for AndroidGCM for Android
GCM for Android
 
Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2
 
Mcq peresentation
Mcq  peresentationMcq  peresentation
Mcq peresentation
 
Introduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedIntroduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting Started
 
Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in Background
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
 
Day 1 Android: Before Getting Started
Day 1 Android: Before Getting StartedDay 1 Android: Before Getting Started
Day 1 Android: Before Getting Started
 
Lecture 5: Storage: Saving Data Database, Files & Preferences
Lecture 5: Storage: Saving Data Database, Files & PreferencesLecture 5: Storage: Saving Data Database, Files & Preferences
Lecture 5: Storage: Saving Data Database, Files & Preferences
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application Development
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
 
Day 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location APIDay 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location API
 

Similaire à Client-Server

Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
SharePoint Saturday NY
 
Unit8 java
Unit8 javaUnit8 java
Unit8 java
mrecedu
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actions
Aren Zomorodian
 

Similaire à Client-Server (20)

Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4...
 
How to build twitter bot using golang from scratch
How to build twitter bot using golang from scratchHow to build twitter bot using golang from scratch
How to build twitter bot using golang from scratch
 
Url programming
Url programmingUrl programming
Url programming
 
Spiffy Applications With JavaScript
Spiffy Applications With JavaScriptSpiffy Applications With JavaScript
Spiffy Applications With JavaScript
 
08 ajax
08 ajax08 ajax
08 ajax
 
Web 2.0
Web 2.0Web 2.0
Web 2.0
 
Mvc acchitecture
Mvc acchitectureMvc acchitecture
Mvc acchitecture
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
 
Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)
 
Major project report
Major project reportMajor project report
Major project report
 
Unit8 java
Unit8 javaUnit8 java
Unit8 java
 
Servlets
ServletsServlets
Servlets
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actions
 
Node js getting started
Node js getting startedNode js getting started
Node js getting started
 
T2
T2T2
T2
 
WP7 HUB_Consuming Data Services
WP7 HUB_Consuming Data ServicesWP7 HUB_Consuming Data Services
WP7 HUB_Consuming Data Services
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
 
B_110500002
B_110500002B_110500002
B_110500002
 

Plus de Ahsanul Karim

Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
Day 4: Activity lifecycle
Day 4: Activity lifecycleDay 4: Activity lifecycle
Day 4: Activity lifecycle
Ahsanul Karim
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
Ahsanul Karim
 
Day 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesDay 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through Activities
Ahsanul Karim
 
Day 2 android internals a quick overview
Day 2 android internals a quick overviewDay 2 android internals a quick overview
Day 2 android internals a quick overview
Ahsanul Karim
 
Sensors in Android (old)
Sensors in Android (old)Sensors in Android (old)
Sensors in Android (old)
Ahsanul Karim
 

Plus de Ahsanul Karim (13)

লেকচার ১ (ক)- শুরুর আগে:
লেকচার ১ (ক)- শুরুর আগে:লেকচার ১ (ক)- শুরুর আগে:
লেকচার ১ (ক)- শুরুর আগে:
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 
Day 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver ComponentDay 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver Component
 
Day 4: Activity lifecycle
Day 4: Activity lifecycleDay 4: Activity lifecycle
Day 4: Activity lifecycle
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
 
Day 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesDay 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through Activities
 
Day 2 android internals a quick overview
Day 2 android internals a quick overviewDay 2 android internals a quick overview
Day 2 android internals a quick overview
 
Mobile Banking in Bangladesh: An Incomplete Study
Mobile Banking in Bangladesh: An Incomplete StudyMobile Banking in Bangladesh: An Incomplete Study
Mobile Banking in Bangladesh: An Incomplete Study
 
List Views
List ViewsList Views
List Views
 
Sensors in Android (old)
Sensors in Android (old)Sensors in Android (old)
Sensors in Android (old)
 
Action Bar Sherlock tutorial
Action Bar Sherlock tutorialAction Bar Sherlock tutorial
Action Bar Sherlock tutorial
 
Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3
 
Android 1.8 sensor
Android 1.8 sensorAndroid 1.8 sensor
Android 1.8 sensor
 

Dernier

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Dernier (20)

HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 

Client-Server

  • 1. Android Application Development Android and Internet Ahsanul Karim ahsanul.karim@sentinelbd.com Sentinel Solutions Ltd. http://www.sentinelbd.com
  • 2. 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.
  • 3. 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
  • 4. 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
  • 5. 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
  • 6. Connecting to the Internet Http Connection Example Now we start with UI components
  • 7. Connecting to the Internet Http Connection Example On button’s action, we add:
  • 8. Connecting to the Internet Http Connection Example Now we run
  • 9. Connecting to the Internet Http Connection Example Now we need to add some checks for internet connection
  • 10. 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
  • 11. 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"} ]
  • 12. Connecting to the Internet Parsing JSON Data