Overcoming Device Fragmentation Problems with J2ME Polish

Overcoming Device Fragmentation Problems with J2ME Polish Introduction J2ME Polish Mobile Technologies Java Technologies Overview ● ● There are...
Author: Kimberly Parker
1 downloads 0 Views 2MB Size
Overcoming Device Fragmentation Problems with J2ME Polish

Introduction J2ME Polish

Mobile Technologies Java Technologies

Overview ●



There are many different, competing mobile technologies Most widespread technology is mobile Java (Java ME / J2ME)



How to overcome problems with J2ME?



Introducing J2ME Polish



Showcase: mobile Wikipedia

Synyx GmbH & Co. KG ●

Founded 2002



Specialized in developing OpenSource Solutions



Specialists for Java from EE via SE to ME and FX



23 Employees



Localized in the center of Karlsruhe

Thomas Kraft ●

Co-Founder of Synyx GmbH & Co KG



Worked actively in several mobile technologies



Open Source enthusiast



Wrote several Articles about J2ME Polish



Co-Author of J2ME Polish book

Rainer Steinegger ●

J2ME Specialist at Synyx GmbH & Co. KG since February 2006



Teaches Mobile Development at Oberstufe



Studies Computer Science at HS Karlsruhe

Introduction J2ME Polish

Mobile Technologies Java Technologies

Mobile Technologies Overview ●

Textmessaging SMS



WAP / Web



Java



BREW



Flash Lite, Silverlight, Java FX





Operating Systems: Symbian, Windows Mobile, Linux, Apple OS X Further Proprietary Technologies (mostly player based)

Mobile Technologies ●

What Technology Should I Use? –

Market Reach



Required Interactivity



Online / Offline Functionality



Availability of Developers



Developer Tools



Runtime Speed



Project Specific Requirements



Fragmentation



...

Fragmentation ●

Mobile device fragmentation limits mobile application adoption and thereby Carriers’ ARPU growth –

Different hardware



Different API Support



Different interpretations of standards



Device bugs

Mobile Technologies Overview Market Reach SMS WAP/ Web Java BREW Flash Lite Symbian etc

Interactivity

Online/ Offline

Availabil Dev. ity of Tools Dev.

Speed

Fragmen tation

Introduction J2ME Polish

Mobile Technologies Java Technologies

Java Technologies ●

Java EE: Enterprise



Java SE: Desktop



Java ME: Mobile



Java Card: Smart Cards, SIMs

Mobile Java Success Story ●





More than 500 billion Java enabled mobile handsets used worldwide Approximately 80% of all handsets shipped with mobile Java support in 2007 Open API extensions provide quick adoption rates for new technologies

Mobile Java Technologies ●

Java ME CLDC + MIDP + Optional APIs



WIPI



DoJa



BlackBerry



Google Android

Mobile Java Development Life Cycle ●

Idea



Conceptual Design



Implementation –

programming: NetBeans, Eclipse, J2ME Polish



debugging: WTK, Vendor Specific Emulators



styling: J2ME Polish



Porting: J2ME Polish



QA on real handsets



Deployment –

OTA



Bluetooth

MIDlet Life Cycle ●

MIDlets are the entry points for applications



Lifecycle





Create in the constructor



(Re)Launch of application in startApp()



Pause of application in pauseApp()



End of application in destroyApp()

public class MyMidlet extends MIDlet { public MyMidlet() {} public void startApp() { Display display = Display.getDisplay(this); display.setCurrent( getStartScreen() ); } public void pauseApp() {} public void destroyApp( boolean force) {} public List getStartScreen() { List list = new List("Main", List.IMPLICIT); list.append("Start", null); list.append("Help", null); list.append("Exit", null); } }

Challenges for Mobile Projects ●

Device Fragmentation



Resource Limits





Memory consumption



JAR size



Speed

Design –

High Level vs. Low Level GUI



Adjusting resources / Customization

Introduction J2ME Polish

Mobile Technologies Java Technologies

Structure of J2ME Polish ●

Device Database



Build Framework



Client API

Build Framework

Client API

Device Database



Further Components: –

Tools



IDE Integration

Device Database ●



Device definitions as the foundation

Build Framework

Client API

Detailed information Device Database about J2ME capable devices - APIs, certificates, screen resolutions, known issues, ...



Used by the Build Framework and the Client API



XML based: easy extensible, web based

Build Framework ●

● ●



Automates necessary steps for creating J2ME apps

Build Framework

Ant based Can be integrated into any IDE

Client API

Device Database

For every target device:

Preprocess

Extensible Compile

Package

Finalize

Emulate

Client API ●



GUI: Lush –

Design outside of the application using CSS



Non standard screens and items



Uses Device Database and Build Framework for adapting and customizing

Device Database

Persistence: Trunk Easy serialization and storage

Server Client Connectivity: Touch –



Client API



– ●

Build Framework

compatible to MIDP 2.0

RMI, XML-RPC, HTML and RSS support

Utilities –

ArrayList, HashMap, IntHashMap, Locale, RgbImage,

Step 1: Programming the MIDlet ●

Basic MIDlet Structure package de.enough.polish.sample.wikipedia; import javax.microedition.lcdui.*; import de.enough.polish.browser.html.HtmlBrowser; import de.enough.polish.event.ThreadedCommandListener; import de.enough.polish.ui.UiAccess; import de.enough.polish.ui.splash.ApplicationInitializer; import de.enough.polish.ui.splash.InitializerSplashScreen; public class WikipediaMidlet extends MIDlet implements CommandListener, ApplicationInitializer { private static final Command CMD_MAIN_MENU = new Command("Main Menu", Command.BACK, 5 ); private static final Command CMD_BACK = new Command("Back", Command.BACK, 5 ); private static final Command CMD_EXIT = new Command("Exit", Command.EXIT, 10); private static final Command CMD_GO = new Command("Go", Command.OK, 2 ); private Display display; private Form browserScreen; private HtmlBrowser htmlBrowser; private List mainMenu; private String defaultUrl = "http://en.wikipedia.7val.com/j2mepolish?startpage=long"; private Form settingsForm; protected void startApp() throws MIDletStateChangeException { // show splash screen during start up } public Displayable initApp() { // application is initialized here } protected void pauseApp(){ // app is paused } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { // nothing to clean up } public void commandAction(Command command, Displayable displayable) { // commands are handled here }

}

Step 1: Programming the MIDlet ●

Initialization protected void startApp() throws MIDletStateChangeException { this.display = Display.getDisplay(this); if (this.mainMenu == null) { try { Image splashImage = Image.createImage("/splash.png"); InitializerSplashScreen splashScreen = new InitializerSplashScreen(this.display, splashImage, 0xffffff, null, 0, this ); this.display.setCurrent( splashScreen ); } catch (Exception e) { //#debug error System.out.println("Unable to create splash screen" + e); Displayable disp = initApp(); this.display.setCurrent( disp ); } } } public Displayable initApp() { //#style screenMain List menu = new List("Wikipedia Menu", Choice.IMPLICIT); //#style itemMain menu.append("Quick Launch", null); //#style itemMain menu.append("Search", null); menu.addCommand( CMD_EXIT ); menu.setCommandListener(this); this.mainMenu = menu;

}

//#style htmlBrowserForm this.browserScreen = new Form("Wikipedia"); //#style htmlBrowser this.htmlBrowser = new HtmlBrowser(); this.browserScreen.append( this.htmlBrowser ); this.browserScreen.addCommand(CMD_BACK); this.browserScreen.addCommand(CMD_MAIN_MENU); this.browserScreen.setCommandListener( new ThreadedCommandListener(this) ); return menu;

Step 2: Design ●

Define Design in polish.css backgrounds { mainBackground { type: horizontal-stripes; first-top-color: #ffff66; first-bottom-color: #008000; second-top-color: #ffffff; second-bottom-color: #33ff00; } }



.screenMain { layout: horizontal-center | vertical-center; margin: 0; padding: 10; padding-vertical: 5; background: mainBackground; }



title { layout: horizontal-center | horizontal-expand; font { face: proportional; size: large; style: bold; color: #000000; } //#if polish.midp2 && polish.hasFloatingPoint text-effect: alien-glow; //#endif background-color: #ffffff;



}

Step 3: Build Application ●

Control Build Process in build.xml / Ant















Step 3: Run Application ●

From within the IDE or the command line ant emulator



Step 4: Deploy Application ●







Add mea lifecycle manager to build.xml: [....]

Build application and upload it on ota.j2mepolish.org

Contact

Synyx GmbH & Co. KG Karlstraße 68 76137 Karlsruhe Germany Phone: +49 - 721 - 66 24 866 Fax: +49 - 721 - 66 48 877 To Download the Wikipedia Application point your mobile browser to http://m.j2mepolish.org

Web: http://www.synyx.de IRC: irc.synyx.de #synyx eMail: [email protected]

Suggest Documents