Bruce Scharlau, University of Aberdeen, 2012 Networking for Mobiles Mobile Computing Some slides from MobEduNet This covers HTTP in detail, and mentions.

Slides:



Advertisements
Similar presentations
Android Application Development A Tutorial Driven Course.
Advertisements

Google Android Introduction to Mobile Computing. Android is part of the build a better phone process Open Handset Alliance produces Android Comprises.
Bruce Scharlau, University of Aberdeen, 2012 Data storage options for mobiles Mobile Computing.
Bruce Scharlau, University of Aberdeen, 2010 Java ME Networking Mobile Computing Some slides from MobEduNet This covers HTTP in detail, and mentions other.
Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from.
Connecting to Databases. connecting to DB DB server typically a standalone application Server runs on localhost for smaller sites –i.e. Same machine as.
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Welcome to Middleware Joseph Amrithraj
COM vs. CORBA.
Introduction.  Professor  Adam Porter 
CS 4720 Mobile Device Architecture CS 4720 – Web & Mobile Systems.
UNDERSTANDING JAVA APIS FOR MOBILE DEVICES v0.01.
ASP.Net, web services--- asynchronous and synchronous and AJAX By Thakur Rashmi Singh.
J2ME Web Services Specification.  With the promise to ease interoperability and allow for large scale software collaboration over the Internet by offering.
The 21th century Repairman Agenda Introduction J2EE J2ME Demonstration.
Cosc 4730 Phone Programming in Java An Introduction.
V1.00 © 2009 Research In Motion Limited Introduction to Mobile Device Web Development Trainer name Date.
Definitions, Definitions, Definitions Lead to Understanding.
SM3121 Software Technology Mark Green School of Creative Media.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
Struts 2.0 an Overview ( )
Android UI, and Networking. Can do most networking on Android Bluetooth only on 2.0, Not supported with version 1.6.
Android Introduction Platform Overview.
Programming mobile devices Part II Programming Symbian devices with Symbian C++
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Advanced Java New York University School of Continuing and Professional Studies.
Chapter 4: Core Web Technologies
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
COM vs. CORBA Computer Science at Azusa Pacific University September 19, 2015 Azusa Pacific University, Azusa, CA 91702, Tel: (800) Department.
Small Devices on DBGlobe System George Samaras Chara Skouteli.
Framework and application bytecode size CLDC MIDP kXML parser Utility classes Graphics Logic (MIDlet) Application Data (XML file)
ANDROID Presented By Mastan Vali.SK. © artesis 2008 | 2 1. Introduction 2. Platform 3. Software development 4. Advantages Main topics.
HOW WEB SERVER WORKS? By- PUSHPENDU MONDAL RAJAT CHAUHAN RAHUL YADAV RANJIT MEENA RAHUL TYAGI.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
Chapter 6 Server-side Programming: Java Servlets
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Concurrency Patterns Emery Berger and Mark Corner University.
tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3.
Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,
CE Operating Systems Lecture 3 Overview of OS functions and structure.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Processes Introduction to Operating Systems: Module 3.
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.
The Problem of State. We will look at… Sometimes web development is just plain weird! Internet / World Wide Web Aspects of their operation The role of.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
ASP.NET (Active Server Page) SNU OOPSLA Lab. October 2005.
1 Java Servlets l Servlets : programs that run within the context of a server, analogous to applets that run within the context of a browser. l Used to.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
 This work confers an application which makes possible to use a Bluetooth enabled mobile phone to remote control home appliances such electric fan, LEDs.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
USING ANDROID WITH THE INTERNET. Slide 2 Lecture Summary Getting network permissions Working with the HTTP protocol Sending HTTP requests Getting results.
The Java Platform Micro Edition Java ME
Introduction to Operating Systems Concepts
Android Mobile Application Development
WWW and HTTP King Fahd University of Petroleum & Minerals
Software Architecture in Practice
CMPE419 Mobile Application Development
Packet Sniffing.
Mobile Handset Virtual Machine
WEB API.
The Application Lifecycle
Application Development A Tutorial Driven Course
Chapter 2: Operating-System Structures
Mobile Programming Dr. Mohsin Ali Memon.
Chapter 2: Operating-System Structures
CMPE419 Mobile Application Development
Presentation transcript:

Bruce Scharlau, University of Aberdeen, 2012 Networking for Mobiles Mobile Computing Some slides from MobEduNet This covers HTTP in detail, and mentions other means. Bluetooth will be covered later.

Windows phones only supports minimal networking Can only use HTTP and push notifications Can use sockets too Bruce Scharlau, University of Aberdeen, 2012

Java uses Internet for direct connections Network operator

Bruce Scharlau, University of Aberdeen, 2012 Java end to end is possible From pdfs at:

Bruce Scharlau, University of Aberdeen, 2012 Network URIs for HttpConnection socket://time-a.nist.gov:13 for StreamConnection serversocket://:4444 for StreamConnectionNotifier comm:0;baudrate=2400 for CommConnection datagram:// for DatagramConnection file://address.dat for FileConnection bluetooth://psm=1001 for StreamConnection

Bruce Scharlau, University of Aberdeen, 2012 Generic Connection Framework

Bruce Scharlau, University of Aberdeen, 2012 Basic Architecture is simple Internet MIDP Device Web Server User requests information from an Application (e.g. MyServlet) Web server passes output from MyServlet back to the MIDlet Web Server launches MyServlet program and sends it parameters the MIDlet requested Web Server retrieves output from the MyServlet

Bruce Scharlau, University of Aberdeen, 2012 Opening a Connection is easy Connection throws IOException so can report errors back to application try { Connection connection = Connector.open( } catch (IOException ioe) { //report error } Connection also has close() method

MIDP 3 is MSA (Mobile Service Architecture) Aims to provide wider functionality for mobiles Should work with CDC and CLDC devices Should allow RFID and NFC object communication Should enable XML parsing Bruce Scharlau, University of Aberdeen, 2012

extra APIs can enhance applications Just remember that they are optional, so may not be available

Bruce Scharlau, University of Aberdeen, 2012 Use JSR 179 and JSR 280 to parse RESTful XML Parse the XML to object on handset Check links on course web site

Bruce Scharlau, University of Aberdeen, 2012 Need to use threads for multi-tasking in application Start a connection in a new thread so the application doesnt hang while waiting for a response

Bruce Scharlau, University of Aberdeen, 2012 Java Object reuse and development Same code in servlet and MIDlet Repeated code in MIDlet

Bruce Scharlau, University of Aberdeen, 2012 Use same OOD principles for MIDlets as for other code Refactor out methods classes Apply design patterns as appropriate Remember that its mobile, so constrain for reduced memory

Bruce Scharlau, University of Aberdeen, 2012 Abstract out repeated code into methods AuctionMIDlet repeats lots of code so that its clear whats happening. These could be removed to a method, or separate class – connection, try/catch, etc There is also the issue of the shared code between the servlet and MIDlet

Bruce Scharlau, University of Aberdeen, 2012 Round trip with octet-stream from client to servlet From pdfs at:

Bruce Scharlau, University of Aberdeen, 2012 Binary code makes it a pure Java solution Tightly coupled to the service. Need to use web services to interoperate with other systems. A change in one will require change in other

Bruce Scharlau, University of Aberdeen, 2012 There are trade-offs between binary and XML From pdfs at:

Can do most networking on Android Bluetooth only on 2.0 onwards – look at that later. Bruce Scharlau, University of Aberdeen, 2012

Android has many components

Bruce Scharlau, University of Aberdeen, 2012 Android emulator runs aslocalhost, ie loopback Emulator is at so need to call service at IP address of service to test network apps on developer machine

Bruce Scharlau, University of Aberdeen, 2012 Activity is one thing you can do From fundamentals page in sdk

Apps move through states during lifecycle Bruce Scharlau, University of Aberdeen, 2012 Source: unlocking android, p 68 onPause is last state to preserve state and cleanup before app possibly destroyed

Method returns string from network Bruce Scharlau, University of Aberdeen, 2012 Log output for debugging, etc Simple method to call URL and return value

Might need helper calls to network Bruce Scharlau, University of Aberdeen, 2012 Put heavy lifting work in HTTPRequestHelper so accessible to other classes Handler waits for message and then returns

Parse xml response and populate Java bean instance Bruce Scharlau, University of Aberdeen, 2012

Add permissions to manifest for connection and network Bruce Scharlau, University of Aberdeen, 2012

Need to consider state in application As with web apps, need to determine if, and how you will deal with state

Bruce Scharlau, University of Aberdeen, 2012 Sessions can maintain state the same as in regular web applications Use either cookies or, preferably, URL rewriting However, network operators might mangle the headers though, so dont rely upon them Some operators use transcoding, which messes up your application See: for detailshttp://wurfl.sourceforge.net/manifesto/index.htm

Bruce Scharlau, University of Aberdeen, 2012 Three levels of software for mobiles Application level is about apps for end users using provided lower-level components Middleware of communication and other libraries for protocols (bluetooth, etc) Low-level software such as kernels and device drivers (platform)

Bruce Scharlau, University of Aberdeen, 2012 Understanding the virtual machine aids development *.class Class loader Execution engine Scheduler Memory manager Bytecode interpreter Run-time data Class area Heap Stack App area loads loads classes into use Garbage collection calls

Bruce Scharlau, University of Aberdeen, 2012 Allow garbage collection to do its job Release early, allocate late: Deallocate objects as soon as possible, and allocate new objects as late as possible

Bruce Scharlau, University of Aberdeen, 2012 Pay attention to your memory usage to improve performance Use what is required for the application. Use single-linked list, instead of double if you only need to traverse it in one direction.

Bruce Scharlau, University of Aberdeen, 2012 Use linear data structures to conserve memory Linear data structures use adjacent memory for their components, instead of separate memory for each item. Linear: linked lists, tables Non-linear: graphs, trees

Bruce Scharlau, University of Aberdeen, 2012 Avoid small classes in favour of larger ones There is a basic overhead for ANY class Inner classes cause the same problem, as does using lots of separate exceptions

Bruce Scharlau, University of Aberdeen, 2012 Avoid dependencies where possible Save items from joining the constant pool of the applications memory load Look to reuse classes already loaded, or use indirection (abstraction)

Break Windows apps into smaller assemblies Load app faster if smaller assemblies (libraries) loaded as needed by app So break architecture into smaller components Bruce Scharlau, University of Aberdeen, 2012

Use Arrays instead of Vectors where possible MethodAllocated bytesAllocated objects arrayImplementation80161 vectorImplementation 40, vectorImplSimple52,

Bruce Scharlau, University of Aberdeen, 2012 Use StringBuffer instead of String MethodAllocated bytesAllocated objects useString39, useStringBuffer3045

Dont access network on UI thread Use separate thread for network so app doesnt hang Bruce Scharlau, University of Aberdeen, 2012

Cache sensible data for speedy response No sense waiting for things we could cache Bruce Scharlau, University of Aberdeen, 2012

Dont ask for too much data either Waiting for too much is no good either: get something on screen and load rest later in background as needed Bruce Scharlau, University of Aberdeen, 2012

Summary Need to consider code reuse carefully to optimise file size (yes, still) Think of garbage collection – release early, allocate late – to help speed Think of what can be done server-side Bruce Scharlau, University of Aberdeen, 2012