Slideshare.net (beta)

 
Post to TwitterPost to Twitter
Post: 
Myspace Hi5 Friendster Xanga LiveJournal Facebook Blogger Tagged Typepad Freewebs BlackPlanet gigya icons

All comments

Add a comment on Slide 1

If you have a SlideShare account, login to comment; else you can comment as a guest


Showing 1-50 of 1 (more)

A Taste of Java ME

From wiradikusuma, 8 months ago

442 views  |  0 comments  |  0 favorites  |  26 downloads
 

Categories

Add Category
 
 

Tags

jamu javame

 
 

Groups / Events

 
Embed
options

More Info

This slideshow is Public
Total Views: 442
on Slideshare: 442
from embeds: 0

Slideshow transcript

Slide 1: A Taste of JavaME Overview to Java’s approach to wireless mobile application development from a developer’s perspective Presentation to the 19th Java User Group Meet Up (JaMU), March 4, 2006 Thomas Wiradikusuma thomas@wiradikusuma.com www.wiradikusuma.com

Slide 2: Objective To introduce JavaME as a platform for developing wireless mobile applications.

Slide 3: Agenda • Wireless mobile environment • JavaME architecture • JavaME versus JavaSE • First MIDlet • User interface and event handling • Persistence • Networking • Game API • Extensions (Messaging, Multimedia, Bluetooth, etc) • Performance

Slide 4: World of Wireless Mobile • Wireless is in the air. • Wireless communication is one of the fastest growing technology. • Cell phones subscribers worldwide exceeded two billions in 2005. • More depended to the Internet, people want it accessible from mobile devices. • 3+G is coming to town.

Slide 5: Meet JavaME • JavaME defined • A little history • Why JavaME? – Dynamic delivery of content – Offline access – Enhanced user experience and interactive content – Cross-platform compatibility – Security – The power of a modern object-oriented programming language – Large developer community

Slide 6: JavaME Architecture

Slide 7: JavaME Architecture, cont’d • Configurations: – Connected Device Configuration – Connected, Limited Device Configuration • Profiles: – Mobile Information Device Profile – PDA Profile – Foundation Profile – etc • Optional packages Typically contains functionality independent of any particular vertical market segment or device family. The main goal is to allow the definition of APIs that can be added flexibly on top of a number of different profiles. One device can support multiple optional packages.

Slide 8: Miniaturized Standard Java APIs • No floating-point in CLDC 1.0. • No user class loading, object finalization, reflection, native methods, demon threads, thread groups, Collections API, etc. • Simpler Runtime and System, java.io, date functions, exception handling, etc. • TIPS: – Always refer to Javadoc. – When compiling, set Language Features and Target VM to lowest Java SDK available (IDEs can help this).

Slide 9: Developing MIDlet • Edit Source Code > Compile > Preverify > Package > Test or Deploy. • Free development tools: – J2ME Wireless Toolkit – EclipseME (an Eclipse plug-in) – NetBeans Mobility Pack (a NetBeans module) • Obfuscation: minimizing the size of MIDlet suite JARs. Originally designed to foil attempts to reverse engineer compiled bytecode, perform any combination of the following functions: – Renaming things to make them compact – Removing unused things – Inserting illegal or questionable data to confuse decompilers • Other useful tools: – Antenna (specialized Ant tasks to help with MIDlet suite builds) – J2ME Polish • Test your application in (varying) real devices as often as possible.

Slide 10: First MIDlet (“Hello World”)

Slide 11: User Interface

Slide 12: Event Handling • A command is something the user can invoke— you can think of it as a button. Like a button, it has a title, like “OK” or “Cancel,” and your application can respond appropriately when the user invokes the command. The premise is that you want a command to be available to the user, but you don't really care how it is shown on the screen or exactly how the user invokes it —keypad button, soft button, touch screen, whatever.

Slide 13: Persisting Data “Record stores”, small database containing pieces of data called records. Represented by instances of javax.microedition.rms.RecordStore.

Slide 14: Connecting to the World • All contained in the javax.microedition.io package and based around the Connection interface. • HTTP (and HTTPS in MIDP 2.0) is mandatory, others are optional.

Slide 15: Connecting to the World, cont’d • TIPS: – Use GET rather than POST. – Don't hard-code URLs. – Put network access in a separate thread. – Handle exceptions gracefully. – Clean up after yourself.

Slide 16: Game API • Simplifies writing 2D games. • GameCanvas’ advantages over Canvas: – Controls exactly when the display is updated – Controls region of the screen to update • Typical game loop: Graphics g = getGraphics(); while(true) { // Check for user input. // Update game state. // Draw stuff using g. flushGraphics(); } • Layer, Sprite, TiledLayer and LayerManager • Special effects: – flashBacklight() – vibrate()

Slide 17: Optional Packages • JSR 120: Wireless Messaging API • JSR 135: Mobile Media API • JSR 172: Web Services Specification • JSR 177: Security and Trust Services • JSR 179: Location API • JSR 180: Session Initiation Protocol (SIP) • JSR 184: Mobile 3D Graphics • JSR 190: Event Tracking API • And a whole lot more…

Slide 18: Performance Issues • Benchmarking – Runtime.freeMemory() – Runtime.totalMemory() – System.currentTimeMilis() – Run multiple times and calculate the average • TIPS: – First make it run, the make it run right, then make it run fast – Create objects efficiently, reuse objects whenever possible – Use StringBuffer for string concatenation – Use arrays, not object collection – Use buffered I/O – Be clean – Make application responsive (“perceived performance”) – Use an obfuscator – Redesign / refactor – Run memory profiler – Manage resources efficiently – Don’t be too OO :-)

Slide 19: Resources • Websites: – wireless.java.sun.com – www.microjava.com – www.onjava.com/onjava/wireless – www.javagaming.com – www.microdevnet.com • Books: – Knudsen, Jonathan. Wireless Java Developing with J2ME, Second Edition. Apress. 2003. – Riggs, Roger, et al. Programming Wireless Devices with the Java™ 2 Platform, Micro Edition, Second Edition. Addison Wesley. 2003.