Android networking 1. Network programming with Android If your Android is connected to a WIFI, you can connect to servers using the usual Java API, like.

Slides:



Advertisements
Similar presentations
Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from.
Advertisements

1/7 ITApplications XML Module Session 8: Introduction to Programming with XML.
CE881: Mobile and Social Application Programming Networking Simon M. Lucas.
USING ANDROID WITH THE INTERNET. Slide 2 Network Prerequisites The following must be included so as to allow the device to connect to the network The.
Web API for Mobile JaxARCSIG April About Me David Fekke L.L.C. Mobile apps for iOS Regular presenter at JaxDUG, JSSUG and JaxFusion Writing Web.
Location based social networking on Android phones – integrated with Facebook. Simple and easy to use.
1 Java Networking – Part I CS , Spring 2008/9.
Ajax / Rich Internet Applications ICW Lecture 21 Errol Thompson.
WHAT IS AJAX? Zack Sheppard [zts2101] WHIM April 19, 2011.
Cosc 4730 Brief return Sockets And HttpClient And AsyncTask.
Client-server interactions in Mobile Applications.
Introduction SOAP History Technical Architecture SOAP in Industry Summary References.
HTTP and Threads. Download some code I’ve created an Android Project which gives examples of everything covered in this lecture. Download code here.here.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Networking Nasrullah. Input stream Most clients will use input streams that read data from the file system (FileInputStream), the network (getInputStream()/getInputStream()),
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
CS378 - Mobile Computing Web - WebView and Web Services.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Concurrency in Android with.
Enabling Embedded Systems to access Internet Resources.
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
Networking: Part 2 (Accessing the Internet). The UI Thread When an application is launched, the system creates a “main” UI thread responsible for handling.
Introduction to Interprocess communication SE-2811 Dr. Mark L. Hornick 1.
4-Oct-15 Basic Protocols. 2 Sockets Sockets, or ports, are a very low level software construct that allows computers to talk to one another When you send.
CSCI 6962: Server-side Design and Programming Web Services.
Networking Android Club Networking AsyncTask HttpUrlConnection JSON Parser.
CS378 - Mobile Computing Web - WebView and Web Services.
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
WEB BASED DATA TRANSFORMATION USING XML, JAVA Group members: Darius Balarashti & Matt Smith.
Chapter 10 Intro to SOAP and WSDL. Objectives By study in the chapter, you will be able to: Describe what is SOAP Exam the rules for creating a SOAP document.
Introduction to Socket Programming in Android Jules White Bradley Dept. of Electrical and Computer Engineering Virginia Tech
MAKANI ANDROID APPLICATION Prepared by: Asma’ Hamayel Alaa Shaheen.
Overview Web Session 3 Matakuliah: Web Database Tahun: 2008.
School of Computing and Information Systems CS 371 Web Application Programming XML and JSON Encoding Data.
JSON and A Comparison of Scripts. JSON: JavaScript Object Notation Based on a subset of the JavaScript Programming Language provides a standardized data.
Internet Technologies Review Week 1 How does Jigsaw differ from EchoServer.java? What abstractions are made available to the servlet writer (under.
CS378 - Mobile Computing Responsiveness. An App Idea From Nifty Assignments Draw a picture use randomness Pick an equation at random Operators in the.
Server - Client Communication Getting data from server.
Introduction to Android
S imple O bject A ccess P rotocol Karthikeyan Chandrasekaran & Nandakumar Padmanabhan.
XML and Object Serialization. Structure of an XML Document Header Root Element Start Tags / End Tags Element Contents – Child Elements – Text – Both (mixed.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
Martin Kruliš by Martin Kruliš (v1.1)1.
Recap of Part 1 Terminology Windows FormsAndroidMVP FormActivityView? ControlViewView? ?ServiceModel? Activities Views / ViewGroups Intents Services.
Intro to Web Services Dr. John P. Abraham UTPA. What are Web Services? Applications execute across multiple computers on a network.  The machine on which.
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
Server-side http General form of http response/request GET request method POST request method Responses Servlet support.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
XML & JSON. Background XML and JSON are to standard, textual data formats for representing arbitrary data – XML stands for “eXtensible Markup Language”
Network Programming. These days almost all devices.
USING ANDROID WITH THE INTERNET. Slide 2 Lecture Summary Getting network permissions Working with the HTTP protocol Sending HTTP requests Getting results.
Messaging and Networking. Objectives Send SMS messages using the Messaging app Send SMS messages programmatically from within your app Receive and consume.
Rest Services with Play Framework, MySQL, Adding Security with JWT
Plan for today Open-Closed and Quizmaster
Rest Services with Play Framework, Adding Security with JWT
Asynchronous Task (AsyncTask) in Android
WWW and HTTP King Fahd University of Petroleum & Minerals
Reactive Android Development
WEB SERVICES.
REST: Web Services Abel Sanchez.
Cosc 5/4730 REST services.
AJAX and REST.
Unit – 5 JAVA Web Services
GF and RS, Dept. of CS, Mangalore University
XML in Web Technologies
MIS JavaScript and API Workshop (Part 3)
CS 240 – Advanced Programming Concepts
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Presentation transcript:

Android networking 1

Network programming with Android If your Android is connected to a WIFI, you can connect to servers using the usual Java API, like – Sockets Low level, general – URLConnection Higher level – HttpURLConnection Higher level, targeted at the HTTP protocol Useful with web services – Etc. Android networking2

Permission to do networking If you Android application will use networking it must be given the right permission – Default: No networking AndroidManifest.xml – Some emulator throws UnknownHostException – Solution: DNS handling in the emulator – internet-on-android-emulator-why-and-how-to-fix internet-on-android-emulator-why-and-how-to-fix Android networking3

Socket Plain old sockets works on Android devices! – WebServices and UrlConnection uses sockets. Example – EchoServer (NetBeans project) – SocketNoTask + SocketUsingTask In modern Android you should not used sockets from the UI thread, since it might make the GUI iresponsive. Solution: More AsyncTask Android networking4

AsyncTask, Just a few words minSdkVersion > 9 – Focus on responsive GUIs – Slow operations cannot be performed from the UI thread Network operations are slow! – Slow operations must be moved to background threads. The class AsyncTask can help you! – Generic: Parameter type, progress type, result type – doInBackGround: The method you want to execute in a background thread – onPostExecute: Method called when doInBackGround has finished. Android networking5

Accessing localhost from the emulator Normally we access servers running on our own computer using the special loop back IP address However, in the emulator, this will refer to the emulator, not the computer running the emulator. A special IP addresses must be used to access the computer running the emulator – for ordinary emulators – for Genymotion emulator Android networking6

URLConnection and HttpURLConnection Two classes from the general Java API – Not special Android API URLConnection – General connection to a server. – Based on a URL HttpURLConnection – HTTP connection to a server – Based on an HTTP URL Like – Example HttpConnectionExample Android networking7

Web services Using SOAP Web services usually uses HTTP for transportation – HttpURLConnection can be used in the client (i.e. the Android application) Web services transport often transports either SOAP documents – SOAP is XML Example: Lee4WebServices2 (Eclipse project) Android networking8

Parsing XML document, Just a few words … The ordinary Java API has two packages related to parsing XML documents – SAX (Simple API for XML) Event based parser – DOM (Document Object Model) Builds an in-memory model of the document. The model can be traversed later Android networking9

Web services using JSON JSON (JavaScript Object Notation) – Pronounced JAY-SON (Like the name Jason) – JSON is not XML It is a simpler text format. Serializing structured data – Without using tags Described in RFC 4627 (2006) – JSON is simpler than SOAP does Uses less network band with Uses less memory + CPU time on the client computer – Example: WebServiceJSON (Eclipse project) Android networking10