application programming

67 %
33 %
Information about application programming

Published on February 4, 2008

Author: Ubert


Mobile Programming:  Mobile Programming Richard Yang Outline:  Outline Admin. and recap Mobile programming Admin.:  Admin. Project reminder: progress report due today Please send to me by email CS colloquium by Prof. Jonathan Smith of UPenn time: 10:30 am location: room 200 topic: software radio Homework 4 to be posted on class home page Recap: Adaptation in Wireless, Mobile Applications:  Recap: Adaptation in Wireless, Mobile Applications Adapt to highly dynamic operating environments to heterogeneous device capabilities Client adaptation e.g., indicate client capability e.g., playout buffer Content adaptation e.g., audio/video: server/proxy coding according to client capability and network status e.g., according to client Accept capability Good example: Wireless Markup Language:  Wireless Markup Language W3C XML-based language Tag-based browsing language: screen management (text, images) data input (text, selection lists, etc.) hyperlinks & navigation support WAP 2.0 is moving towards XHTML-MP, but WML is still popular WML High-Level Structure:  WML High-Level Structure WML pages are called DECKS Each deck consists of a set of CARDS, related to each other with links When a WML page is accessed from a mobile phone, all the cards in the page are downloaded from the WAP server Slide7:  WML Elements Deck/Card Elements wml card template head access meta Tasks go prev refresh noop Event Elements do ontimer onpick onevent postfield onenterforward onenterbackward Variables setvar User input input select option optgroup fieldset Anchors, Images, and Timers a anchor img timer Text Formatting br p table tr td Slide8:  WML Example <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" ""> <WML> <CARD> <DO TYPE=“ACCEPT”> <GO URL=“#eCard”/> </DO> Welcome! </CARD> <CARD NAME=“eCard”> <DO TYPE=“ACCEPT”> <GO URL=“/submit?N=$(N)&S=$(S)”/> </DO> Enter name: <INPUT KEY=“N”/> Choose speed: <SELECT KEY=“S”> <OPTION VALUE=“0”>Fast</OPTION> <OPTION VALUE=“1”>Slow</OPTION> <SELECT> </CARD> </WML> Navigation Path: An Example:  <card id="Login" title="Login"> <do type="accept" label="Password"> <go href="#Password"/> </do> <p> UserName: <select name="name" title="Name:"> <option value="John Doe">John Doe</option> <option value=“Paul Smith">Paul Smith</option> </select> </p> </card> <card id="Password" title="Password:"> <do type="accept" label="Results"> <go href="#Results"/> </do> <p> Password: <input type="text" name="password"/> </p> </card> <card id="Results" title="Results:"> <p> You entered:<br/> Name: $(name)<br/> Password: $(password)<br/> </p> </card> Navigation Path: An Example WAP: Status:  WAP: Status There is an up swing of WAP usage, but problems limiting its usage uses a new language (WML) -> no good authoring tool, no content takes the lowest common denominators in terms of hardware support although WAP gateway can provide adaptation, the result is less than ideal WAP can handle push contents, but weak in interactive applications In Japan, iMode is the equivalent of WAP, and is far more popularly used than WAP iMode uses cHTML (compact HTML) rather than WML Application Development: General Mobile Programming Environment:  Application Development: General Mobile Programming Environment Discussion:  Discussion What are the major considerations in developing a general programming environment for mobile wireless applications? Windows .NET Compact Framework:  Windows .NET Compact Framework Scales down a popular programming environment to ease learning the .NET CF is a subset of the full .NET framework with some additions designed for resource constrained devices 1,400 classes for .NET CF vs. 8,000 for full 27 UI controls for .NET CF vs. 52 for full 1.5 MB for .NET CF vs. 30 MB for full Uses versioning to avoid using lowest common denominator pocket PC pocket PC phone version smart phone version Uses virtual machines to mask device heterogeneity programming languages compile to MSIL MSIL is JIT compiled on the device MSIL code is smaller than native executables MSIL allows your code to be processor independent Java2 Micro Edition (J2ME):  Java2 Micro Edition (J2ME) J2ME :  J2ME Approach very similar to .NET Compact (or .NET Compact similar to J2ME?) Based on Java Uses “versioning” to avoid using lowest common denominator Uses java virtual machines to mask device heterogeneity J2ME:  J2ME Java2 is divided into three platforms J2EE (Java2 Enterprise Edition) business applications J2SE (Java2 Standard Edition) general applications J2ME (Java2 Micro Edition) small devices such as mobile phone, PDA, car navigation J2ME Versioning:  J2ME Versioning To accommodate heterogeneous mobile devices, define configurations and profiles A configuration provides fundamental services for a broad category of devices (e.g., lang, io, util) A profile supports higher-level services common to a more specific class of devices or market (e.g., life cycle, GUI) An optional package adds specialized services that are useful on devices of many kinds, but not necessary on all of them J2ME:  J2ME 128-512K mem 16-32 bit proc Upto 2M mem 32 bit proc Two Available J2ME Configurations:  Two Available J2ME Configurations Connected Limited Device Configuration (CLDC) 160 KB to 512 KB of total memory available 16-bit or 32-bit processor low power consumption and often operating with battery power connectivity with limited bandwidth many Java features deleted, e.g., floating point, finalize examples: cell phones, certain PDAs Connected Device Configuration (CDC) 2 MB or more memory for Java platform 32-bit processor high bandwidth network connection, most often using TCP/IP examples: set-top boxes, certain PDAs Available J2ME Profiles:  Available J2ME Profiles Mobile Information Device Profile (MIDP) delivers an enhanced user interface, multimedia and game functionality, end-to-end security, and greater networked connectivity to mobile phones and entry level PDAs Foundation Profile set of Java APIs that support resource-constrained devices without a standards-based GUI system Personal Profile Together with CDC and Foundation Profile, Personal Profile provides a complete application environment for the high-end PDA market. Personal Profile contains the full set of AWT APIs, including support for applets and Xlets Personal Basis Profile provides a J2ME application environment for network-connected devices supporting a basic level of graphical presentation Mobile Phone Framework:  Mobile Phone Framework Typical J2ME Technology Stack:  Typical J2ME Technology Stack CLDC Available Packages:  CLDC Available Packages java.lang java.util CLDC: java.lang:  CLDC: java.lang Boolean Byte Character Class Integer Long Math Object Runnable Runtime Short String StringBuffer System Thread Throwable Calendar Date Enumeration Hashtable Random Stack TimeZone Vector ByteArrayOutputStream ByteArrayInputStream DataOuput DataInput DataInputStream DataOutputStream InputStream InputStreamReader OutputStream OutputStreamWriter PrintStream Reader Writer java.lang java.util MIDP Hardware:  MIDP Hardware Memory (added to CLDC memory) 128 KB non-volatile for MIDP components 8 KB non-volatile for application persistent data 32 KB volatile for KVM Display screen 96x54 display depth 1-bit pixel shape (aspect ratio) 1:1 MIDP Hardware:  MIDP Hardware Input (one or more) one-handed keyboard (ITU-T phone keypad) two-handed keyboard (QWERTY keyboard) or touch screen Networking two-way wireless possibly intermittent limited bandwidth Slide27:  MIDP Packages java.lang java.util javax.microedition.lcdui javax.microedition.rms javax.microedition.midlet javax.microedition.pki addition in version 2.0 version 1.0 MIDP Application Model:  MIDP Application Model An MIDP application is called a MIDlet similar to the J2SE applet GUI based MIDlet suites – for applications that share resources or data MIDP: Application Lifecycle:  MIDP: Application Lifecycle MIDlets move from state to state in the lifecycle, as indicated start – acquire resources and start executing pause – release resources and become quiescent (wait) destroy – release all resources, destroy threads, and end all activity startApp destroyApp pauseApp destroyApp Slide30: import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class HelloWorldMIDlet extends MIDlet implements CommandListener { private Command exitCommand; private Display display; private TextBox t; public HelloWorldMIDlet() { display = Display.getDisplay(this); exitCommand = new Command("Exit", Command.EXIT, 2); t = new TextBox(“CS434", "Hello World!", 256, 0); t.addCommand(exitCommand); t.setCommandListener(this); } public void startApp() { display.setCurrent(t); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command c, Displayable s) { if (c == exitCommand) { destroyApp(false); notifyDestroyed(); } } } Slide31:  MIDP: GUI Implementations control the look and layout of screen components Title High-level Components Ticker tape (Optional; device manufacturer can place it at the top or bottom of the screen) MIDP: GUI:  Lists Text Boxes Alerts Forms Form Items Labels Image Items String Items Text Fields Date Fields Gauges Choice Groups For examples: see UIDemo Similar to J2SE GUI but reduced MIDP: GUI MIDP: Connection:  MIDP: Connection Based on a framework called the Generic Connection Framework (GCF) GCF consists of an interface hierarchy that is extensible a connection factory, and uses Standard Uniform Resource Locators (URLs) to indicate the connection types to create scheme://user:password@host:port/url-path;parameters e.g. socket:// file:///myResourceFile.res datagram:// sms://+12034326400 Developing J2ME Applications:  Developing J2ME Applications Identify the devices Identify the profiles supported by devices using the MID profile, the application will target cell phones and pagers Develop application install jdk, a package supporting the wireless target (e.g., Sun Wireless Toolkit for CLDC) debug using a simulator for deployment, preverify by pre-generating “stack map” Deploying: Two-Phase Class File Verification Process:  Stack map attribute increases the size of a classfile by appro. 5% but substantially reduces device mem and CPU usage Deploying: Two-Phase Class File Verification Process Deploying:  Deploying Generate deployment files: two files Java Application Description file (.jad) Java archive file (.jar) Upload .jad and .jar to the device or a server where the device can download the application Over-The-Air Application Loading Process:  Over-The-Air Application Loading Process

Add a comment

Related presentations