Transcript
Page 1: Nokia Series 40 Full Touch Training - Dec 08 2012

Nokia Series 40 Full Touch Training

08 Dec 2012, Ho Chi [email protected]

Page 2: Nokia Series 40 Full Touch Training - Dec 08 2012

2

Page 3: Nokia Series 40 Full Touch Training - Dec 08 2012

Series 40Platform NewFeatures

Page 4: Nokia Series 40 Full Touch Training - Dec 08 2012

Device Family

› SDK 2.0

› SDK 1.1

› Touch-and-type

› Non-touch

› S40 6th Edition FP1

› S40 6th Edition

› S40 5th Edition Fp1

› ...

Page 5: Nokia Series 40 Full Touch Training - Dec 08 2012

Series 40Platform: Newand Enhanced

Features

› Keyboard check

› Back button

› Category bar

› Status bar

› Header bar

› Forms and text input

› PopupList

Page 6: Nokia Series 40 Full Touch Training - Dec 08 2012

Series 40Platform: Newand Enhanced

Features

› Full screen and commandsmenu

› Badge API

› Theming

› Pinch gesture

› Multi-touch

› Fixed and dynamicorientation

Page 7: Nokia Series 40 Full Touch Training - Dec 08 2012

Series 40Platform: Newand Enhanced

Features

› Font STYLE_LIGHT

› VideoDecode control

› Maps new features

› Locale listener

› Using new sensors

› Additional system properties

Page 8: Nokia Series 40 Full Touch Training - Dec 08 2012

Asha 305, 2.5G, Dual SIM, Resistive Touch

Maximum User Storage: 10 MB

(Additional 2GB memory card included)

ROM Memory: 64 MB

RAM Memory: 32 MB

Maximum Memory Card Size: 32 GB

Maximum Heap Size: 2 MB

Maximum JAR Size: 2 MB

Page 9: Nokia Series 40 Full Touch Training - Dec 08 2012

Asha 306, 2.5G, WLAN, Resistive Touch

Maximum User Storage: 10 MB

(Additional 2GB memory card included)

ROM Memory: 64 MB

RAM Memory: 32 MB

Maximum Memory Card Size: 32 GB

Maximum Heap Size: 2 MB

Maximum JAR Size: 2 MB

Page 10: Nokia Series 40 Full Touch Training - Dec 08 2012

Asha 311, WLAN, 3G, Capacitive Touch

Maximum User Storage: 140 MB

ROM Memory: 256 MB

RAM Memory: 128 MB

Maximum Memory Card Size: 32 GB

Maximum Heap Size: 4 MB

Maximum JAR Size: 2 MB

Page 11: Nokia Series 40 Full Touch Training - Dec 08 2012

Asha 308, 2.5G, Dual SIM, Capacitive Touch

Maximum User Storage: 20 MB

(Additional 2GB memory card included)

ROM Memory: 128 MB

RAM Memory: 64 MB

Maximum Memory Card Size: 32 GB

Maximum Heap Size: 2 MB

Maximum JAR Size: 2 MB

Page 12: Nokia Series 40 Full Touch Training - Dec 08 2012

Asha 309, 2.5G, WLAN, Capacitive Touch

Maximum User Storage: 20 MB

(Additional 2GB memory card included)

ROM Memory: 128 MB

RAM Memory: 64 MB

Maximum Memory Card Size: 32 GB

Maximum Heap Size: 2 MB

Maximum JAR Size: 2 MB

Page 13: Nokia Series 40 Full Touch Training - Dec 08 2012

(Device View Video)Asha 305, Asha 311

Page 14: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 15: Nokia Series 40 Full Touch Training - Dec 08 2012

Series 40 Phones

Filter by Series 40 Edition orJava Runtime version (new phones)

developer.nokia.com/Devices

Page 16: Nokia Series 40 Full Touch Training - Dec 08 2012

Series 40 & Java RuntimeJava Runtime Series 40 Version Phones

2.0.0 Series 40 Asha 305, 306, 311, 308, 309

1.1.0 Series 40 Asha 200, 201, 302, 303

1.0.0 Series 40 Asha 202, 203, C2-00, C2-02, C2-03, C2-05, C2-06,X2-02, X2-05

N/A Series 40 6th Edition, FP 1 Asha 300, C3-01, X3-02

N/A Series 40 6th Edition C2-01, C3-00, X2-00, X2-01, 6303i, 7230, 6350, 6750,3720, ...

N/A Series 40 6th Edition Lite C1-01, C1-02

N/A Series 40 5th Edition, FP1 2690, 3208, 6600i, 2730, 2700, 6208, 6600, 8800, ...

N/A Series 40 5th Edition, FP1 Lite 2220, 2720, 2320, 2330, 5000...

N/A Series 40 5th Edition 3610, 6263, 6555, 7500, 6267

Page 17: Nokia Series 40 Full Touch Training - Dec 08 2012

CLDC MIDP 248MSA

185JTWI

75File

82BT

135Media

172WebRPC

172WebXML

177SATSAAPD

U

177SATSACRY

PT

179Locati

on

1843D

205Messaging

211Conte

nt

226SVG

234Audio

3D

234Came

ra

234Music

256Senso

r

NokiaUI

IAP

2.0.0 1.1 2.1 1.1 - 1.0 1.1 1.2 1.0 1.0 1.0 1.0 1.0 1.1 2.0 1.0 1.1 1.1 1.1 1.1 1.0 1.6 2.0

1.1.0 - - 1.1 1.0

1.0.0 - - 1.1b -

S406th,FP1

- - 1.1b -

S406th

√ - √ - 1.1 -

S406thLite

- √ - - - - - - -

S405thFP1

√ - 1.1 - √ 1.0 - 1.0 - -

S405th

FP1 L

- √ - - - - - - - - - - - -

S405th

√ - 1.1 1.0 1.0 - 1.1 - √ 1.0 - 1.0 - -

Page 18: Nokia Series 40 Full Touch Training - Dec 08 2012

(HelloWorld Video)

Page 19: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 20: Nokia Series 40 Full Touch Training - Dec 08 2012

Remote Device Access» Now supports Series 40

– Free for Nokia Developer users

– Deploy & Test apps

– http://www.developer.nokia.com/Device

s/Remote_device_access/

Page 21: Nokia Series 40 Full Touch Training - Dec 08 2012

UI Style&

Screen Elements

Page 22: Nokia Series 40 Full Touch Training - Dec 08 2012

Full Touch› 2 or 5 point multi-touch

› Resistive or capacitive

› 240x400 screen

Page 23: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 24: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 25: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 26: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 27: Nokia Series 40 Full Touch Training - Dec 08 2012

Full Touch UI» Screen

– 240 x 400 Pixels

– 3:5 aspect ratio

– Previous QVGA = 3:4

– Affects UI of canvas-based app

» New features:

– Action buttons

– Category bar

– Back button

Page 28: Nokia Series 40 Full Touch Training - Dec 08 2012

Back Button› Automatically added to

lower right corner for thehighest priorityCommand.BACK orCommand.EXIT

› Any additional BACK or EXITcommands of lower priorityare on the drop down menu

Page 29: Nokia Series 40 Full Touch Training - Dec 08 2012

Action Button

› Automatically added to topleft corner for the highestpriority Command.OK

› Use IconCommand tospecify the icon

› Otherwise it is

Page 30: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 31: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 32: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 33: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 34: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 35: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 36: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 37: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 38: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 39: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 40: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 41: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 42: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 43: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 44: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 45: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 46: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 47: Nokia Series 40 Full Touch Training - Dec 08 2012

Get and setup the tools:

1. Check your system requirements.

2. Download JDK 6 Update 27 and install it.

3. Download the NetBeans IDE’s ‘all’ package and install it.

4. Download the Nokia SDK 2.0 for Java and install it.

5. Download Nokia Suite and install it.

6. Activate the Java ME option in NetBeans using Plugins ontheTools menu.

7. Add your SDK to NetBeans’ list of Java platforms, using JavaPlatforms on the Tools menu.

Java - Getting started with NetBeans IDE

Page 48: Nokia Series 40 Full Touch Training - Dec 08 2012

Java - Getting started with NetBeans IDE

https://www.developer.nokia.com/Develop/Java/Getting_started/NetBeans/

Page 49: Nokia Series 40 Full Touch Training - Dec 08 2012

Demo- Form elements

Page 50: Nokia Series 40 Full Touch Training - Dec 08 2012

Exercises

Page 51: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 52: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 53: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 54: Nokia Series 40 Full Touch Training - Dec 08 2012

Status Bar» Show status zone in full screen app

public class MainCanvas extends Canvas{

public MainCanvas(){

// Activate full screen modesetFullScreenMode(true);

// Make status bar visibleLCDUIUtil.setObjectTrait(this,

"nokia.ui.canvas.status_zone",Boolean.TRUE);

}}

Example: PaintApp

Page 55: Nokia Series 40 Full Touch Training - Dec 08 2012

Category Bar

› Use only to change views,not to perform actions

› Actions can be icons, but donot belong in a “CategoryBar”

› Works on Form and Canvas

Page 56: Nokia Series 40 Full Touch Training - Dec 08 2012

CategoryBar» Typical use: view switching

– One element always highlighted

– Mandatory & automatic back button

» CategoryBar.getMaxElements() (excluding back)

– Currently: 15 icons (+ back)

– Portrait: 4 visible, landscape: 6 visible

– Excess (> 15) icons not shown

» CategoryBar.getBestImageWidth / Height()

– Currently: 44 x 44

– Note: size is edge-to-edge. Make actual icon smaller! (e.g., 20 x 20)

44 x 44 icon

20 x 20 icon

Page 57: Nokia Series 40 Full Touch Training - Dec 08 2012

CategoryBar» Back

– Traditional back Command in Form

– Visible w/o CategoryBar

– CommandListener

– CategoryBar

– Back included by default

– ElementListener.BACK

→ always visible if usingCategoryBar: no back cmd needed

Back command,CategoryBar visible

Page 58: Nokia Series 40 Full Touch Training - Dec 08 2012

IconCommand» Extends LCDUI Command class

– Adds: Icon

– Built-in system icon

– Own icon (unselected, [selected])

» Icons visible

– Action button 1

– Category bar

– Back button always has default icon, not possible to override!

Actionbutton 1

Category bar

Page 59: Nokia Series 40 Full Touch Training - Dec 08 2012

Using: IconCommandpublic class JavaFTMidlet extends MIDlet implements CommandListener {

private Form frmMain;private IconCommand cmdOk;

public JavaFTMidlet() {frmMain = new Form("Main");cmdOk = new IconCommand("Ok", Command.OK, 1, IconCommand.ICON_OK);frmMain.addCommand(cmdOk);

}

public void startApp() {frmMain.setCommandListener(this);Display.getDisplay(this).setCurrent(frmMain);

}

public void commandAction(Command c, Displayable d) {if (c == cmdOk) { /* Ok Command */ }

}}

Command mappedto action button 1

Very few predefinedicons are available

Example: JavaTouch

Page 60: Nokia Series 40 Full Touch Training - Dec 08 2012

Using: CategoryBarpublic class JavaFTMidlet extends MIDlet implements CommandListener, ElementListener {

private IconCommand cmdHome;private IconCommand cmdInfo;

public JavaFTMidlet() {try { // Load icon images

Image imgHome = Image.createImage("/home.png");cmdHome = new IconCommand("Home", imgHome, imgHome, Command.SCREEN, 3);//cmdHome = new IconCommand(“Home", “Home", Command.SCREEN, 3, IconCommand.ICON_SEND_SMS);Image imgInfo = Image.createImage("/info.png");cmdInfo = new IconCommand("Info", imgInfo, imgInfo, Command.SCREEN, 3);//cmdInfo = new IconCommand(“Info", “Info", Command.SCREEN, 3, IconCommand.ICON_OPTIONS);

} catch (IOException ex) { }

IconCommand[] iconCommands = {cmdHome, cmdInfo}; // Put commands into arrayCategoryBar categoryBar = new CategoryBar(iconCommands, true);categoryBar.setVisibility(true); // Make visible (default: invisible)categoryBar.setElementListener(this); // For notifyElementSelected() callback

}

public void notifyElementSelected(CategoryBar cb, int i) {Alert alert = new Alert("Element");if (i == ElementListener.BACK) { // Default back element from category bar

alert.setString("Back element"); // i == -1} else {

alert.setString("Element: " + i); // Element ID: 0, 1, 2, ... starting left}display.setCurrent(alert);

}

Element 0 selectedby default

Using same icon forhighlighted state

ElementListener forCategoryBar

Example: JavaTouch

Page 61: Nokia Series 40 Full Touch Training - Dec 08 2012

Demo- Standard CategoryBar- Custom CategoryBar

Page 62: Nokia Series 40 Full Touch Training - Dec 08 2012

PopupListPopupList list1 = new PopupList();PopupList list2 = new PopupList();list2.setItemText("Sublist");

PopupListItem item1 = new PopupListItem("Text");PopupListItem item2 = new PopupListItem("Text", image1);PopupListItem item3 = new PopupListItem("Text2");PopupListItem item4 = new PopupListItem("Text3", image1);

list1.appendItem(item1);list1.appendItem(item2);list1.appendItem(list2);list2.appendItem(item3);list2.appendItem(item4);

list1.setVisible(true);

Example: Menu

Page 63: Nokia Series 40 Full Touch Training - Dec 08 2012

Method Summary

voidappendItem(PopupListItem item)

This method will append an item to the list.

PopupListItemgetItem(int index)

Returns the item specified by the index from the popuplist.

voidinsertItem(PopupListItem item, int index)

This method will insert an item to the list at the give index.

voidremoveItem(PopupListItem item)

This will remove the item from the popuplist.

voidremoveItemAt(int index)

This will remove the item specified by the index from the popuplist.

voidsetItemText(java.lang.String text)

Deprecated. will be removed soon, use the setText instead of

voidsetListener(PopupListListener listener)

This method sets the PopupListListener for this list.

voidsetListYPos(int yPos)

Sets the y coordinate where the contextual menu should be shown.

voidsetTailStyle(int style)

This sets the tail style for the contextual menu.

voidsetText(java.lang.String text)

This method sets the PopupList item text.

voidsetVisible(boolean visible)

This sets the list visible or hidden.

intsize()

This will return the size of the popuplist.

Page 64: Nokia Series 40 Full Touch Training - Dec 08 2012

Demo- PopupList

Page 65: Nokia Series 40 Full Touch Training - Dec 08 2012

Orientation

› You can

› Get and set screen orientationwith the Orientation class

› Alternate: system property toget orientation

› Receive changes as registeredOrientationListener

› Use a JAD parameter to lock toeither portrait or landscape

Page 66: Nokia Series 40 Full Touch Training - Dec 08 2012

com.nokia.mid.ui.orientation.Orientation

Page 67: Nokia Series 40 Full Touch Training - Dec 08 2012

Interface com.nokia.mid.ui.orientation.OrientationListener

› Use in your Canvas, GameCanvas or CustomItem

› Change object height, width or layout for pleasing effects

Page 68: Nokia Series 40 Full Touch Training - Dec 08 2012

Orientation» By default, your app is locked portrait only

» To enable landscape/portrait orientation changes

1. Add attribute:

Nokia-MIDlet-App-Orientation: manual

2. Register yourself as an OrientationListener

public class JavaFTMidlet extends MIDlet implements OrientationListener {public void startApp() {

Orientation.addOrientationListener(this);}

Page 69: Nokia Series 40 Full Touch Training - Dec 08 2012

Orientation Example: JavaTouch

portraitlandscape

ormanual

portraitlandscape

ormanual

Page 70: Nokia Series 40 Full Touch Training - Dec 08 2012

Orientation– Adapt content orientation to phone / display

– setAppOrientation() calls sizeChanged() on the current Displayable

– This allows you to intercept the changes before they occur and filter or customize

public void displayOrientationChanged(int newDisplayOrientation) {switch (newDisplayOrientation) {

case Orientation.ORIENTATION_PORTRAIT:case Orientation.ORIENTATION_PORTRAIT_180:

Orientation.setAppOrientation(Orientation.ORIENTATION_PORTRAIT);break;

case Orientation.ORIENTATION_LANDSCAPE:case Orientation.ORIENTATION_LANDSCAPE_180:

Orientation.setAppOrientation(Orientation.ORIENTATION_LANDSCAPE);break;

}}

Example: JavaTouch

Page 71: Nokia Series 40 Full Touch Training - Dec 08 2012

Demo- Orientation on Form- Orientation on Canvas

Page 72: Nokia Series 40 Full Touch Training - Dec 08 2012

ProceduralGraphics

› Translucent drawing

› Any size text fonts

› New font: Light

Page 73: Nokia Series 40 Full Touch Training - Dec 08 2012

Nokia ScalableFonts

Font font =DirectUtils.getFont(face,style, customHeight);

› On some less expensivephones, this will failgracefully to a standard Fontsize

› Very handy for makingsubtly styled user interfaces

Page 74: Nokia Series 40 Full Touch Training - Dec 08 2012

”Light” Font

› Use DirectUtils.getFont() withDirectUtils.STYLE_LIGHT

› You may also add anycombiation of

› Font.STYLE_BOLD

› Font.STYLE_ITALIC

› Font.STYLE_UNDERLINE

› This may also degradegracefully to a different fontdepending on the phone

Page 75: Nokia Series 40 Full Touch Training - Dec 08 2012

Demo- Scalable Font- Alpha blending

Page 76: Nokia Series 40 Full Touch Training - Dec 08 2012

Input: Text andTouch Input

Page 77: Nokia Series 40 Full Touch Training - Dec 08 2012

TextEditorVirtual Keyboard, Physical Keyboard

Multi-touchGestures

Page 78: Nokia Series 40 Full Touch Training - Dec 08 2012

Checkingkeyboard

type

› String keyboard =Sytem.getProperty(”com.nokia.keyboard.type”);

”None”

”PhoneKeypad”

”LimitedKeyboard4x10”

”LimitedKeyboard3x11”

”HalfKeyboard”

”Custom”

”Unknown”

COMMON WITHCURRENT S40 PHONES

Page 79: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 80: Nokia Series 40 Full Touch Training - Dec 08 2012

Standard MIDP does not support textinput onCanvas. So you can create yourown, or change the view to a full screen

TextBox which is not a good userexperience.

Page 81: Nokia Series 40 Full Touch Training - Dec 08 2012

TextEditor › Custom Nokia class

› Text input on top of Canvas

› Define exactly where on thescreen, all colors andtranslucency

› Pricise control, no chrome.Adapt it to your application’slook and feel.

› TextEditorListener allows youto monitor user changes live

TransparentRectangle?

Page 82: Nokia Series 40 Full Touch Training - Dec 08 2012

Alpha Rect

void fillAlphaRect(Graphics g, int color, int x, int y, int w, int h){

int[] rgb = new int[w * h];

for (int i = 0; i < w * h; i++){

rgb[i] = color;}

g.drawRGB(rgb, 0, w, x, y, w, h, true);}

Page 83: Nokia Series 40 Full Touch Training - Dec 08 2012

TextEditorproperties

› View properties

› Position

› Size

› Visibility

› Focus state

› Color properties

› Background color with alpha channel

› Background highlight color with alphachannel

› Foreground color with alpha channel

› Foreground highlight color with alphachannel

Page 84: Nokia Series 40 Full Touch Training - Dec 08 2012

TextEditorproperties

› Text properties

› Caret position

› Editor constraints

› Text font

› Text selection

› Text content

› Maximal length of text

› Multiline

› Other properties

› Initial input modes

› Text editor listener

› Receiving pointer events

Page 85: Nokia Series 40 Full Touch Training - Dec 08 2012

TextEditorListenerevents

Page 86: Nokia Series 40 Full Touch Training - Dec 08 2012

TextEditor» Text entry on aCanvas (custom UI)

– MIDP: only fullscreenTextBox(bad UX)

– Create own editor (not easy!)

» NokiaTextEditorclass

– Since Java Runtime 1.0.0

– Define position, look & feel

– Full VKB support

– Input modes: similar toTextField(email, numeric, pwd, etc.)

– Landscape & portrait

– Listener available to check input, control caret movement, etc.

86

© 2012 Nokia Java ME Touch v1.0.1 April 4, 2012 Andreas Jakl

Page 87: Nokia Series 40 Full Touch Training - Dec 08 2012

Using: Text Editor» Show & hide text editor in the Canvasprotected void pointerPressed(int x, int y) {

if (x >= textBoxX && x < textBoxX + textBoxWidth && y >= textBoxY && y < textBoxY + textBoxHeight) {// Click in the box, show the text editor: no input constraints, 20 chars max lengthtextEditor = TextEditor.createTextEditor(text, 20, TextField.ANY, textBoxWidth, textBoxHeight);textEditor.setForegroundColor(0xFFFFFFFF); // Text color: whitetextEditor.setBackgroundColor(0x800092c2); // Transparent blue background (Alpha = 0x80)textEditor.setParent(this); // Canvas to draw ontextEditor.setPosition(textBoxX, textBoxY); // x/y coordinatestextEditor.setVisible(true); // By default invisibletextEditor.setFocus(true); // Deliver keys to textEditor, not to CanvastextEditor.setCaret(text.length()); // Caret at end of text

} else if (textEditor != null) {// Click outside of the box, defocus the text editortext = textEditor.getContent(); // Copy text contentstextEditor.setParent(null);textEditor = null;

}repaint();

}

Example: CanvasTextEditor

Page 88: Nokia Series 40 Full Touch Training - Dec 08 2012

Using: Text Editor» Draw text when TextEditor not active / visibleprotected void paint(Graphics g) {

if (textEditor == null) {g.setColor(0xFFFFFF);g.drawRect(textBoxX - 2, textBoxY - 2, textBoxWidth, textBoxHeight);g.drawString(text, textBoxX, textBoxY, Graphics.TOP | Graphics.LEFT);

}}

Example: CanvasTextEditor

Page 89: Nokia Series 40 Full Touch Training - Dec 08 2012

Demo- TextEditor

Page 90: Nokia Series 40 Full Touch Training - Dec 08 2012

Virtual Keyboard» Use on-screen keyboard on Canvas

– Creates keyPressed() callbacks

– Get VKB height to avoid content overlap

VKB_MODE_ALPHA_LOWER_CASE

VKB_MODE_DEFAULT

Page 91: Nokia Series 40 Full Touch Training - Dec 08 2012

Using: Virtual Keyboard» Show keyboard

» Hide keyboar

CustomKeyboardControl vkbControl = VirtualKeyboard.getCustomKeyboardControl();vkbControl.launch(VirtualKeyboard.VKB_TYPE_ITUT, VirtualKeyboard.VKB_MODE_ALPHA_LOWER_CASE);

vkbControl.dismiss();

Example: PaintApp

Page 92: Nokia Series 40 Full Touch Training - Dec 08 2012

Using: Virtual Keyboardpublic class MainCanvas extends Canvas implements KeyboardVisibilityListener{

private int screenHeight;private int visibleHeight;

public MainCanvas() {setFullScreenMode(true);screenHeight = getHeight(); // Original screen height == 400visibleHeight = screenHeight; // No VKB visible -> == 400VirtualKeyboard.setVisibilityListener(this);

}public void showNotify(int keyboardCategory) {

// VKB now visible -> visibleHeight == 200visibleHeight = screenHeight - VirtualKeyboard.getHeight();

}public void hideNotify(int keyboardCategory) {

// VKB now hidden -> visibleHeight == 400visibleHeight = screenHeight;

}}

visibleHeight == 200

visibleHeight == 400

Example: PaintApp

Page 93: Nokia Series 40 Full Touch Training - Dec 08 2012

Automatic Key Simulation» No touch handling in

Canvas?

– Drag gestures automatically

trigger simulated key events

– Up, Down, Left, Right

– “open keypad” command

added to menu

Example: KeyAnalyzer

Page 94: Nokia Series 40 Full Touch Training - Dec 08 2012

Demo- Virtual Keyboard

Page 95: Nokia Series 40 Full Touch Training - Dec 08 2012

Multipoint Touch» Single touch

– Canvas.pointerPressed() part of MIDP

– Only tracks 1st touch point

» Multipoint Touch

– Tracks multiple touch points

– But use simpler gesture APIs when possible

– Each associated with unique ID, x, y and state

– Call-back for touch changes, but status available any time

– Use in: Canvas-/CustomItem-based classes

Page 96: Nokia Series 40 Full Touch Training - Dec 08 2012

Using: Multipoint Touch» Number of touch points

– Limited accuracy of simultaneous touch points on a resistive screen → no

on-screen joystick & shoot button possible!

» Register: touch point listener

MultipointTouch mpt = MultipointTouch.getInstance();int numTouchPoints = MultipointTouch.getMaxPointers();

== 2 on the emulatorand first phone

public class MainCanvas extends Canvas implements MultipointTouchListener{

public MainCanvas() {// ...mpt.addMultipointTouchListener(this);

}

Example: PaintApp

Page 97: Nokia Series 40 Full Touch Training - Dec 08 2012

Using: Multipoint Touch» Handling touch eventspublic void pointersChanged(int[] pointerIds) {

for(int i=0; i<pointerIds.length; i++) { // Loop through the changed touch points{

int pointerId = pointerIds[i]; // Get the touch point IDint state = MultipointTouch.getState(pointerId); // Get the touch point state// Get the touch point x and y coordinatesint x = MultipointTouch.getX(pointerId);int y = MultipointTouch.getY(pointerId);

// Handle the UI update based on the touch point state, ID and coordinatesswitch(state) {

case MultipointTouch.POINTER_PRESSED: // A new finger was pressed against the screendrawTouch(pointerId, x, y); break;

case MultipointTouch.POINTER_DRAGGED: // A pressed finger was dragged over the screendrawTouch(pointerId, x, y); break;

case MultipointTouch.POINTER_RELEASED: // A pressed finger was lifted from the screenbreak;

} } }

Example: PaintApp

Page 98: Nokia Series 40 Full Touch Training - Dec 08 2012

Single Touch› Sytem.getProperty(”

com.nokia.pointer.number “)== “1”;

Page 99: Nokia Series 40 Full Touch Training - Dec 08 2012

Non-Touch

› Canvas.hasPointerEvents()== false

› UX: You must highlight thecurrently selected item. Ontouch, you only highlight thecurrent item to providevisual feedback until the endof the pointer event.

Page 100: Nokia Series 40 Full Touch Training - Dec 08 2012

Example: Optional Multitouch» Encapsulate API using code to separate class

» Check support and instantiate on demand

public class MultitouchManager implements MultipointTouchListener {MainCanvas canvas;

public MultitouchManager(MainCanvas canvas) {this.canvas = canvas;MultipointTouch mpt = MultipointTouch.getInstance();mpt.addMultipointTouchListener(this);

}

public void pointersChanged(int[] pointerIds) { /* ... */ }}

if (System.getProperty("com.nokia.mid.ui.multipointtouch.version") != null) {// API is supported: Can implement multipoint touch functionalitymultiManager = new MultitouchManager(this);useMultitouch = true;

}

protected void pointerPressed(int x, int y) {if (!useMultitouch) {

// Handle touch event// on single-touch phone

}}

In MainCanvas class(extends Canvas)

Hint: only handleCanvas.pointerPressed()on single touch phones

Example: PaintApp

Page 101: Nokia Series 40 Full Touch Training - Dec 08 2012

Demo- Multitouch (Emulator & Device)

Page 102: Nokia Series 40 Full Touch Training - Dec 08 2012

Gestures

Page 103: Nokia Series 40 Full Touch Training - Dec 08 2012

Gesture APIDetect additional touch

and motion events

12/8/2012 103

Page 104: Nokia Series 40 Full Touch Training - Dec 08 2012

Touch GesturesSingle TapLong PressLong Press RepeatedDragDropFlick

Page 105: Nokia Series 40 Full Touch Training - Dec 08 2012

Gesture Components

Page 106: Nokia Series 40 Full Touch Training - Dec 08 2012

Gestures – step 1» Create a GestureInteractiveZone

// Create a GestureInteractiveZone for all Gesture Types

GestureInteractiveZone giz = new GestureInteractiveZone(GestureInteractiveZone.GESTURE_ALL );

// set bounding rectangle of zone.

giz.setRectangle( x, y, width, height);

Page 107: Nokia Series 40 Full Touch Training - Dec 08 2012

Gestures – step 2// Define a GestureListener

Class GestureCanvas extends Canvas implements GestureListener {

protected void paint(Graphics g) { … }

public void gestureAction( Object container,

GestureInteractiveZone zone, GestureEvent event) {

...

}

}

Page 108: Nokia Series 40 Full Touch Training - Dec 08 2012

Gestures – step 3» Register the GestureInteractiveZone with the GestureRegistrationManager

// Register for Gesture events.

Canvas canvas = new GestureCanvas();

GestureRegistrationManager.register( canvas, giz );

GestureRegistationManager.setListener( canvas, canvas );

Page 109: Nokia Series 40 Full Touch Training - Dec 08 2012

Handling gestureAction()public void gestureAction( Object container,

GestureInteractiveZone zone, GestureEvent event) {

switch( event.getType() ) {

case GestureInteractiveZone.GESTURE_TAP:

case GestureInteractiveZone.GESTURE_LONG_PRESS:

case GestureInteractiveZone.GESTURE_LONG_PRESS_REPEATED:

case GestureInteractiveZone.GESTURE_DRAG:

case GestureInteractiveZone.GESTURE_DROP:

case GestureInteractiveZone.GESTURE_FLICK:

}

}

Page 110: Nokia Series 40 Full Touch Training - Dec 08 2012

GestureEvent DetailsMethodsint getType()

int getStartX()

int getStartY()

int getDragDistanceX()

int getDragDistanceY()

float getFlickDirection() returns flick direction in radians

int getFlickSpeed()

int getFlickSpeedX()

int getFlickSpeedY()

Page 111: Nokia Series 40 Full Touch Training - Dec 08 2012

Gesture Flick Direction• getFlickDirection returns float which is the direction in radians

Page 112: Nokia Series 40 Full Touch Training - Dec 08 2012

Gesture Usage Notes»Don’t block the Event Dispatch Thread (EDT) in

gestureAction(…)

»Don’t hold on to the GestureEvent instance

It is only guaranteed for duration of gestureAction()

Page 113: Nokia Series 40 Full Touch Training - Dec 08 2012

Touch Gestures» Use in: Canvas-/CustomItem-based classes. Combine with Frame

Animator API for Drag & kinetic scrolling

– Tap: press and release

– Long Press (& repeated): press and hold

– Drag: press and move

– Drop: press, move, release

– Flick: press, move, release

– Pinch (new!): two fingers, move one in-out or around

Page 114: Nokia Series 40 Full Touch Training - Dec 08 2012

Using: Gestures» Register as gesture listener

– Zone: reacts to 1+ specified gestures

– Whole screen or rectangular area

– Overlap possible

– Received events→GestureListener

public class MainCanvas extends Canvas implements GestureListener {private int curPinchDistance = -1;public MainCanvas() {

// Set this as container (gesture source) and listenerGestureRegistrationManager.setListener(this, this);// Register for pinch events in the whole canvas areagestureZone = new GestureInteractiveZone(GestureInteractiveZone.GESTURE_PINCH);GestureRegistrationManager.register(this, gestureZone);

}

Example: PaintApp

Page 115: Nokia Series 40 Full Touch Training - Dec 08 2012

Using: Gestures» Handling gestures

– gestureAction() executed in UI thread

– Lengthy operations (scaling image, etc.) → own thread!

public void gestureAction(Object container, GestureInteractiveZone gestureInteractiveZone, GestureEvent gestureEvent) {int eventType = gestureEvent.getType();switch (eventType) {

case GestureInteractiveZone.GESTURE_PINCH: // Pinch detectedcurPinchDistance = gestureEvent.getPinchDistanceCurrent(); break;

case GestureInteractiveZone.GESTURE_RECOGNITION_START: /* ... */ break;case GestureInteractiveZone.GESTURE_RECOGNITION_END: /* ... */ break;

}}

Example: PaintApp

Page 116: Nokia Series 40 Full Touch Training - Dec 08 2012

Demo- Gesture

Page 117: Nokia Series 40 Full Touch Training - Dec 08 2012

Motion Inputand Interaction

Page 118: Nokia Series 40 Full Touch Training - Dec 08 2012

Sensors, AccelerometersFrame AnimationLocation, Maps

Page 119: Nokia Series 40 Full Touch Training - Dec 08 2012

Sensors

» JSR 256 Sensor API

› Generic: designed also for temperature, blood pressure,etc.

› Also available on Symbian

» Currently supported

› Battery Charge: 0 .. 100, charge percentage

› Network Field Intensity: 0 .. 100, signal strength

› Charger State: 0 .. 1, charger connected

› Acceleration: –2g .. +2g, x / y / z axis

› Double Tap: 1 .. 63, phone sides

› Orientation: 0 .. 6, phone orientation

Page 120: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 121: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 122: Nokia Series 40 Full Touch Training - Dec 08 2012

Double Tap Sensor

http://www.developer.nokia.com/Resources/Library/Java/_zip/GUID-F031C633-5F4E-441E-A863-CE4E28A9CD55/appendixE.html

Page 123: Nokia Series 40 Full Touch Training - Dec 08 2012

Finding Sensors

Application SensorManager SensorInfo Connector

findSensors(quantity,contextType)

return SensorInfo[]

getUrl()

return URL

Connector.open(URL)

return SensorConnection

Page 124: Nokia Series 40 Full Touch Training - Dec 08 2012

Sensor Values» Modes

– Synchronous

– Poll sensor

– Example: accelerometer in game loop

– Asynchronous

– DataListener callbacks

– Example: phone charger plugged in

Page 125: Nokia Series 40 Full Touch Training - Dec 08 2012

Using: Sensors» Establish sensor connection

» Check data in game loop

// Find all acceleration sensors, the contextType is left undefinedSensorInfo[] sensorInfos = SensorManager.findSensors("acceleration", null);// Find an acceleration sensor that returns double valuesfor (int i = 0; i < sensorInfos.length; i++) {

if (sensorInfos[i].getChannelInfos()[0].getDataType() == ChannelInfo.TYPE_DOUBLE) {accSensor = (SensorConnection) Connector.open(sensorInfos[i].getUrl());

}}

// Use 1 as a buffer size to get exactly 1 value for each axisData[] data = accSensor.getData(1);speedX = -data[0].getDoubleValues()[0]; // data[0] => x-axisspeedY = data[1].getDoubleValues()[0]; // data[1] => y-axis

Example: MovingBall

Page 126: Nokia Series 40 Full Touch Training - Dec 08 2012

Accelerometers

Page 127: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 128: Nokia Series 40 Full Touch Training - Dec 08 2012

Demo- Car Race- Double Tap Soccer (Device)

Page 129: Nokia Series 40 Full Touch Training - Dec 08 2012

Location

› Traditional ”location” APIsuse GPS

› Network-based location isfaster to give a result, butthe result is less precise

› There are several variantsavailable. The phone will pickthe most precise among theoptions you consideracceptable.

Page 130: Nokia Series 40 Full Touch Training - Dec 08 2012

Cell ID Positioning» Approximate location using cell ID

– Online, ~ 5kB per request

» Specifically using cell ID positioning

– Request generic LocationProvider through Nokia’s LocationUtil

– No continuous updates (Listener) → 1-time, synchronous requests

– Run in own thread

– Raw cell ID: com.nokia.mid.cellid system property *

//Specify the retrieval method to Online/Cell-IDint[] methods = {(Location.MTA_ASSISTED | Location.MTE_CELLID | Location.MTE_SHORTRANGE | Location.MTY_NETWORKBASED)};// Retrieve the location providerLocationProvider provider = LocationUtil.getLocationProvider(methods, null);// 50 seconds time-outLocation loc = provider.getLocation(50000);// Get longitude and latitudeQualifiedCoordinates coordinates = loc.getQualifiedCoordinates();

* Series 40 5th Eition FP1 +: Manufacturer & Operator Domains. Java Runtime 1.0.0+: all domains

Example: mapExample

Page 131: Nokia Series 40 Full Touch Training - Dec 08 2012

LocationUtil» The com.nokia.mid.location.LocationUtil class provides an extra mechanism for creating

a LocationProvider

» This is an extension to the JSR-179 Location API, which provides the LocationProvider class

class LocationUtils {

static LocationProvider LocationUtil.getLocationProvider(int[] preferedMethods,String parameters );

}

» The parameters is for additional platform parameters, for now use null

Page 132: Nokia Series 40 Full Touch Training - Dec 08 2012

LocationUtil» The preferedMethods can be a combination of the following

definitions of the JSR-179 Location class:MTA_ASSISTED

MTA_UNASSISTED

MTE_CELLID

MTE_SATELLTITE

MTE_SHORTRANGE

MTY_NETWORKBASED

MTY_TERMINALBASED

Page 133: Nokia Series 40 Full Touch Training - Dec 08 2012

Cell-ID Based Location» A MIDlet can obtain approximate location by using the Cell-ID based

method

» This method will send to a network based server the cell-id that thephone is connected to. This server will return the known location ofthat cell-id

» This enabled phones without built in GPS to obtain an approximateLocation without requiring a separate Bluetooth GPS device

» Note using Cell-ID based location, the coordinates can vary from a fewmeters to hundreds of kilometers, depending on the local networkdeployment and on how much information the backend database hasbeen able to collect for that area

Page 134: Nokia Series 40 Full Touch Training - Dec 08 2012

Cell-ID Example Code» Example code:

int[] methods = {(Location.MTA_ASSISTED |

Location.MTE_CELLID |

Location.MTY_NETWORKBASED)};

LocationProvider lp = LocationUtil.getLocationProvider(methods,null);

Location loc = lp.getLocation(-1);

Coordinates coords = loc.getQualifiedCoordinates();

double lat = coords.getLatitude();

double lng = coords.getLongitude();

Page 135: Nokia Series 40 Full Touch Training - Dec 08 2012

Maps

Page 136: Nokia Series 40 Full Touch Training - Dec 08 2012

Maps API for Java ME

Now in Nokia Java SDK 2.0(previously separate plug-in package)

http://www.developer.nokia.com/Develop/Maps/Maps_API_for_Java_ME/

Page 137: Nokia Series 40 Full Touch Training - Dec 08 2012

Supported Features» Maps

» Search

» (Reverse) Geocoding

» Routing

» Sharing: convert to URL

» Note: now always requires AppID and Token

Page 138: Nokia Series 40 Full Touch Training - Dec 08 2012

Map ViewFeatures

» Multiple map types – conventional streetmap, satellite and terrain

» Touch support – use touch to pan and zoomthe map

» Customizable markers – set color, labels andimages

» Polygons, polylines – set colors andtransparency levels

» Overlay support – set color/labels or usecustom images

» Download indicator – provided as a standardUI component

Page 139: Nokia Series 40 Full Touch Training - Dec 08 2012

Using: Maps

public class MapMidlet extends MIDlet {public void startApp() {

// Set registered application ID and tokenApplicationContext.getInstance().setAppID("xxx");ApplicationContext.getInstance().setToken("xxx");

// Create new Nokia Maps canvasDisplay display = Display.getDisplay(this);MapCanvas mapCanvas = new MapCanvas(display);

// Show map on the screendisplay.setCurrent(mapCanvas);

}}

// Geocode an addressSearchManager searchManager = SearchManager.getInstance();searchManager.geocode("Vienna, Austria", null);Location[] locations = searchManager.getLocations();

// Center map on the latitude and longitudemapCanvas.getMapDisplay().setCenter(locations[0].getDisplayPosition());mapCanvas.getMapDisplay().setZoomLevel(11, 0, 0);

Example: mapExample

Page 140: Nokia Series 40 Full Touch Training - Dec 08 2012

2G Network LocationVs

3G Network Location

Page 141: Nokia Series 40 Full Touch Training - Dec 08 2012
Page 142: Nokia Series 40 Full Touch Training - Dec 08 2012

Maps Package Overview» The API is divided into four packages.

Package Description

com.nokia.maps.common Common classes needed by other packages including Address,ApplicationContext, GeoBoundingBox and GeoCoordinate.

com.nokia.maps.map Map package contains classes needed to show and interact with mapcontent and place objects on map.

com.nokia.maps.routing Routing package contains classes to calculate route and access route data.PositioningManager provides an easy to get current location informationbased on GPS device or device cell information.

com.nokia.maps.search Search package contains SearchManager for geocoding and reversegeocoding.

Page 143: Nokia Series 40 Full Touch Training - Dec 08 2012

The Minimal LBSP App» Displaying interactive map to the user is simple as creating

MapCanvas instance and setting it as a current displayable:

import com.nokia.maps.map.MapCanvas;

/*** Minimal MIDP application to show map content to the user.*/public class MapMIDlet extends MIDlet {

/*** This method is called when the application is started and sets* MapCanvas as a current Displayable.*/protected void startApp() throws MIDletStateChangeException {

Display display = Display.getDisplay(this);MapCanvas mapCanvas = new MapCanvas( display );display.setCurrent(mapCanvas);

}}

Page 144: Nokia Series 40 Full Touch Training - Dec 08 2012

Map

Page 145: Nokia Series 40 Full Touch Training - Dec 08 2012

Map Markers» A Marker can be added to a map with the following code:

double lat = 51.3;double lng = 0.8;int size = 10;String s = “You are here!”;GeoCoordinate coord = new GeoCoordinate(lat, lng, 0 );MapFactory mapFactory = mapCanvas.getMapFactory();MapStandardMarker marker =

mapFactory.createStandardMarker(coord, size, s);mapCanvas.getMapDisplay().addMapObject( marker );

Page 146: Nokia Series 40 Full Touch Training - Dec 08 2012

Map Marker

Page 147: Nokia Series 40 Full Touch Training - Dec 08 2012

Other Map Markers» The MapFactory class defines other types of Map Markers:

MapMarker createMapMarker( GeoCoordinate coordinate, Image image );

MapCircle createMapCircle( double radius, GeoCoordinate centre );

MapRectangle createMapRectangle( GeoBoundingBox boundingBox );

MapPolygon createMapPolygon( GeoCoordinate[] coordinates );

MapPolyline createMapOptPolyline( GeoCoordinate[] coordinates );

Page 148: Nokia Series 40 Full Touch Training - Dec 08 2012

Search Manager» Places can be searched for with the SearchManager

» You can also look up locations near a specified GeoCoordinate

// Get instance of SearchManagerSearchManager searchManager = SearchManager.getInstance();searchManager.setListener(this);

// Look up locations based on a search stringsearchManager.geocode( “Germany,Berlin", null );

// Or, get locations at specified GeoCoordinateGeoCoordinate coord = new GeoCoordinate(51.3, 0.8, 0 );searchManager.reverseGeocode( coord );

Page 149: Nokia Series 40 Full Touch Training - Dec 08 2012

Search Listener» The SearchListener allows a MIDlet to get notification when a search

request is completed

public class MySearchListener implements SearchListener {

public void searchRequestError(SearchManager source, Throwable error){

// Handle search error}

public void searchRequestFinished(SearchManager source) {// Can now get the search resultsLocation[] locations = source.getLocations();

}

public void searchResponseCleared(SearchManager source) {}

}

Page 150: Nokia Series 40 Full Touch Training - Dec 08 2012

Routing» RouteManager provides access to Ovi routing service

» Calculating route requires at least two waypoints and wanted modes

» Modes are used to control route calculation features

// Create the waypoints

GeoCoordinate start = new GeoCoordinate(51.3, 0.8, 0);GeoCoordinate end = new GeoCoordinate(55.0, 0.0, 0);WaypointParameterList waypoints = new WaypointParameterList();waypoints.addCoordinate(start);waypoints.addCoordinate(end);

RouteManager rm = RouteManager.getInstance();rm.setListener(this);// Use default routing modeRoutingMode[] modes = { new RoutingMode() };rm.calculateRoute(waypoints, modes );

Page 151: Nokia Series 40 Full Touch Training - Dec 08 2012

Route Listenerpublic void calculateRouteRequestFinished(RouteManager rm) {

Route[] routes = rm.getRoutes();Maneuver m = route[0].getFirstManeuver();while( m != null ) {

String s = m.getInstruction();…m = m.getNextManeuver();

}}

public void routeRequestError(RouteManager rm,Throwable error) {// handle error condition

}

public void routeResponseCleared(RouteManager rm) {// route cleared

}

Page 152: Nokia Series 40 Full Touch Training - Dec 08 2012

Routing Mode» A RoutingMode consists of:

› A routing type

› A list of transport modes

› A list of routing options

public RoutingMode(int routingType,int[] transportModes,

java.lang.String[] routingOptions);

Page 153: Nokia Series 40 Full Touch Training - Dec 08 2012

Routing Types» The Routing Type must be one of the types defined in

RoutingType

» These are static intsRoutingType.DIRECT_DRIVE

RoutingType.ECONOMIC

RoutingType.FASTEST

RoutingType.FASTEST_NOW

RoutingType.SCENIC

RoutingType.SHORTEST

Page 154: Nokia Series 40 Full Touch Training - Dec 08 2012

Transport Modes» The following transport Modes are available

TransportMode.BICYCLE

TransportMode.CAR

TransportMode.PEDESTRIAN

TransportMode.PUBLICTRANSPORT

TransportMode.TRUCK

Page 155: Nokia Series 40 Full Touch Training - Dec 08 2012

Routing Options» These are string constants defines in RoutingOptions

NOTE: HOVLANE = High occupancy vehicle lane

RoutingOptions.AVOID_BOATFERRY

RoutingOptions.AVOID_DIRTROAD

RoutingOptions.AVOID_MOTORWAY

RoutingOptions.AVOID_PARK

RoutingOptions.AVOID_PUBLICTRANSPORT

RoutingOptions.AVOID_RAILFERRY

RoutingOptions.AVOID_STAIRS

RoutingOptions.AVOID_TOLLROAD

RoutingOptions.AVOID_TUNNEL

RoutingOptions.PREFER_HOVLANE

Page 156: Nokia Series 40 Full Touch Training - Dec 08 2012

Custom Display» So far the example used a MapCanvas which performs all the Map rendering

» The LBSP API also allows you to use the MapDisplay directly, to provide a greatercontrol on how the Maps are rendered to the canvas

MapFactory mapFactory = MapFactory.createMapFactory(MapDisplayType.TILE_MAP,

MapResolutionEnum.MAP_RESOLUTION_128_x_128, getWidth(), getHeight());

MapDisplay map = mapFactory.createMapDisplay();

» Display Type can be either: TILE_MAP or VECTOR_MAP

» Resolution can be either: 128 x 128 or 256 x 256

Page 157: Nokia Series 40 Full Touch Training - Dec 08 2012

Using MapDisplay» You can then render the map on your own Canvas with

renderMap(Graphics)

protected void paint(Graphics g) {map.renderMap(g);

}

» Alternatively, you can render the map to an Image instead andthen use that Image wherever you like

Image image = Image.createImage( width, height );Graphics g = image.getGraphics();map.renderMap(g);

Page 158: Nokia Series 40 Full Touch Training - Dec 08 2012

Custom Display Screenshot

Page 159: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

In-app Purchase

Page 160: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

In-app PurchaseThe boss is too hard? Purchase more skills to defeat it!

Page 161: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

What is In-app Purchase (IAP)In-app purchase (IAP) allowsyou to integrate a Nokia Storepurchasing feature into yourS40 Java application in asimple and seamless manner.

End users (consumers)can purchaseadditional digitalcontent or servicesdirectly from yourapplication, withouthaving to leave theapplication.

Page 162: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

With in-app purchase, you can• Sell add-ons, levels, and

virtual goods to enhance theengagement and lengthenthe lifetime of yourapplications

• Convert free applications to paid ones byembedding try-and-buy offers within theapplications

• Offer seamless consumer-friendly creditcard and operator payment flows tooptimize the purchase funnel

Page 163: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

With in-app purchase, you can

• Enjoy rich revenue sharing with the sameprice points and earnings split as forNokia Store content

• Implement purchases through a fewsimple API calls, without having to worryabout payment processing

• Leverage Nokia's numerous operator billingintegrations and country presences to extend yourreach and promote your brand

Operator BillingNOW live inVietnam!

Page 164: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

What you can sell• Premium levels for games• Virtual goods, such as

additional tools or currencyfor a game

• Downloadable components,such as city guides for alocation-based application

Content

• One-time subscriptions forvarious periods, such as aone-month, three-month, orone-year subscription to amobile newspaper

• Donations

Services

Page 165: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

What you can NOT sell

Tickets to real-world events

Physical goods, such as pizza

Physical merchandise in online auctions

Purchases that Nokia's Quality Assurance (QA) team cannot verify at the timeof submission, such as loyalty points or prepayments for future releases

Content that does not adhere to Nokia Publish

Page 166: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Device compatibilityJava Runtime 1.1.0 Java Runtime 2.0.0

Page 167: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

How are purchased items delivered

• Bundled in the app downloaded fromNokia Store to a device

• On a publisher back end server

Nokia Store handles the payment processing

Page 168: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

How do you restore content

How the content is restored depends on the content type

When end users buy new devices,they lose ownership or access to

content they purchased through in-app purchase

Your application must provide a wayfor end users to restore their

ownership or access

Built–in content

Nokia Store handlesthe restoration

Content deliveredfrom a back-end

server

You handle therestoration

Page 169: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Payment flowYour application:

• Sends a request to Nokia Store for the purchasable contents' prices and descriptions

• Displays the available purchases within the application

• Prompts users to purchase content

• Prompts the user to confirm the content purchase and payment method, either credit card or operator billing

• Displays any required error messages, disclaimers, and notifications

• Displays a notification of a successful payment

Page 170: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Purchasing process with DRM protected content1. To be able to display the purchasable items to the end user, the

application must know the IDs of the products that are availablefor purchase. You use Nokia Publish to identify in-app purchaseitems and get IDs for them.

2. Nokia Store returns the product metadata (name, price, anddescription) that matches the given product IDs.

3. The application displays the items to the end user, using themetadata received.

4. The end user selects which item they want to purchase, andpresses a Buy button.

5. The application triggers a payment process using the in-apppurchase API.

6. Nokia Store processes the payment, and completes thetransaction. The process includes prompting the user for theirNokia account password, if the user is not yet signed in, andprompting for the confirmations needed.

Note: If Nokia Store notices after the sign-in that the end user actually hasa right to restore this item without any cost, it switches from a purchaseprocess to a restoration process.

7. Nokia Store delivers the DRM key to unlock the protectedcontent on the device.

Page 171: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Restoration process with DRM protected content

You can design therestoration process for your

application in a number ofdifferent ways

Provide a menu optionto the user to check forany restorable items in

Nokia Store

Display a Restoreoption. User can

attempt a restorationwhich may fail if the

user is not entitled torestoring it

Auto-switch from apurchase process to a

restoration process

• Nokia Store makes sure thatthe end user does not pay fora DRM protected item if theyare entitled to restore it freeof charge

• This is verified based on theuser’s account and device

• If the item is eligible forrestoration, Nokia Storeswitches from a purchaseprocess to a restorationprocess

Page 172: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Nokia Store sign-in• To purchase content or restore, the end user must sign in to Nokia Store

• During the time that the sign-in is valid, the end user can purchase or restore without having to sign in again

• Nokia Store may prompt for username and password if

User sign in to Nokia Store for the first time on their device

The end user has not allowed the device to store this data

In a restoration scenario

• If the end user is signed in

The application tries to silently check if any restorable products are available and display restoration options

Silently restore them without requiring any action from the user

• If the end user is not signed in, they will not automatically be bothered with a password prompt unless they specifically select a UI option tofind out

Page 173: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Steps to implement in-app purchase

Choose a methodfor contentprotection

Add informationabout the in-app

purchase items toNokia Publish

Create the in-apppurchase resourcefiles used by the

application

Implement the in-app purchase

feature

Verify the purchase(if applicable)

Handle DRM-protected content

(if applicable)

Provide end usersupport

Test the in-apppurchase feature

Submit theapplication toNokia Publish

• Nokia Publish tests the application and applies DRM protectionif requested, and, if the application passes QA, publishes theapplication to Nokia Store.

• Using OMA DRM 2.0 to encrypt resource files that are not in-app purchases is not currently supported in Java

Page 174: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

IAP Project Structure• IAP_VARIANTID.TXT

Create in the root of the application project's resourcefolder

Open the file in a text editor, enter "000000" and save thefile

Used by Nokia Publish to store the application's uniqueidentifier before the application is published to Nokia Store

• TEST_MODE.TXT Required for testing the application on Nokia Publish server

Bypass money transactions

Nokia Store automatically removes this file beforepublishing

Page 175: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

IAP Project Structure• DRM protected resources

Store the resource files for each purchase item in<project_root>\<resource_folder>\drm\data\resourceid_x

x is the unique ID of the corresponding purchase item (Product ID)

• Where to get Product ID?

Register on Nokia Publish

• Access to protected resource files:

getDRMResourceAsStream

• Normal resources (non-DRM protected)

Other folders in the project except<project_root>\<resource_folder>\drm

• Access to unprotected resource files:

getDRMResourceAsStream

getResourceAsStream

Page 176: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

IAP classes

Interface Summary

IAPClientPaymentListener The IAPClientPaymentListener represents a listener that receives events associated with the IAPClientPaymentProvider.

Class SummaryDrmResourceInputStream

IAPClientPaymentManager This is the main class for initiating and managing the purchase process for the purchaseable items in an application.

IAPClientProductData Class for holding purchaseable or restorable product specific data.

IAPClientUserAndDeviceData Class for holding User and Device Data related information.

Exception SummaryIAPClientPaymentException The IAPClientPaymentException is thrown when any unexpected system error occurs.

Package com.nokia.mid.payment

Page 177: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

IAP callback functionsInterface IAPClientPaymentListener

Method Summaryvoid productDataListReceived(int status, IAPClientProductData[] productDataList)

This callback function is executed when the request for a list of product data to the Nokia Store back end is complete.

void productDataReceived(int status, IAPClientProductData pd)This callback function is executed when the product data request for the Nokia Store back end is complete.

void purchaseCompleted(int status, java.lang.String purchaseTicket)This callback function is executed when the IAPClient gets information from the Nokia Store back end indicating that the purchase has been completed.

void restorableProductsReceived(int status, IAPClientProductData[] productDataList)This callback function is executed when the request for products available for restoration is complete.

void restorationCompleted(int status, java.lang.String purchaseTicket)This callback function is executed when the IAPClientPaymentProvider gets information from the Nokia Store back end indicating that the item's restoration is

possible.

void userAndDeviceDataReceived(int status, IAPClientUserAndDeviceData ud)This callback function is executed when the user and device data request is completed.

Page 178: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Basic IAP Code Flow

1. import com.nokia.mid.payment.*;

2. public class IAP implements IAPClientPaymentListener

3. IAPClientPaymentManager pManager = IAPClientPaymentManager.getIAPClientPaymentManager();

4. pManager.setIAPClientPaymentListener(this);

5. pManager.getProductData(“123456”);

6. public void productDataReceived(int status, IAPClientProductData productData)

7. pManager.purchaseProduct(“123456”, IAPClientPaymentManager.FORCED_AUTOMATIC_RESTORATION);

8. InputStream is = pManager.getDRMResourceAsStream("/drm/data/ResourceId_123456/extra_levels.dat”);

Page 179: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Config emulator

Diagnostics window

Display debug logs

Display http requests/responses

Page 180: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Application DetailsChoose Tools > IAP Simulation

• Click Create button to create anew IAP application

• Click Browse button to declarepath to the project folder, whichyou want to integrate IAP. It willautomatically add res folder toyour project:

• IAP_VARIANTID.TXT

• TEST_MODE.TXT

• drm subfolder

Page 181: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

In-app purchases• Add button to create a new IAP item (product

ID). ID can be any number, for example“123456”

• Display name, Short Description and LongDescription is the product metadata

• Global Price Point means how much you wantto sell

• Ticket information is retrieved once user haspurchased the IAP item successfully

Page 182: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Restore and Restorable ProductsRestore Product

• Config whether the IAP item can berestored or not

• For the selected In-app ID, set its restoreresult as Success (with Purchase Ticketinformation) or Fail

Restorable Product Details

• Config the list of retrieved IAP itemswhen calling getRestorableProductsmethod

• Select all In-app IDs from the given list,which can be retrieved or choose Fail asreturn result

Page 183: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

DRM Access, User and Device DataDRM Access

• Config whether the correspondingIAP resource files can be accessedwith getDRMResourceAsStreammethod

User and Device Data

• Config user and device informationwhich are retrieved when callinggetUserAndDeviceId method

Page 184: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Testing IAP – Emulator VS DeviceFeatures

Use SDK Local Simulation Test with Nokia Publish Server Test with real device

Purchase process

Restore process

DRM Access

User and Device Data

Nokia Store sign-in

Real money transaction

Config in TEST_MODE.TXT

Page 185: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Testing IAP – Emulator VS DeviceRequirements

Use SDK Local Simulation Test with Nokia Publish Server Test with real device

Register In-app ID onNokia Store

Not Required Required Required

Nokia Store account Not Required Required Required

Network Not Required Required Required

Sim card Not Required Not Required Required

IAP supported Phone (Asha) Not Required Not Required Required

Page 186: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Testing IAP – Emulator VS DeviceTEST_MODE.TXT configuration

testservertestMode=normal

The server works as if in production mode, but does not process payments. Products in Nokia Store can have differentrestoration policies. Some products may not be restorable at all. The Normal test mode means that the restoration policythat has been configured to Nokia Store for the product will be used.

testservertestMode=purchase

The server treats all purchases as first-time purchases, and never converts purchases to restorations. You can purchasethe same item repeatedly.

testservertestMode=fail

The server always returns failure after payment confirmation. This works only for purchase and not for restore.

testservertestMode=restore

The server converts already purchased items to restorations. To simulate this, you must purchase an item at least once.After the first purchase, the item is marked as restorable (with any IMEI or account) and subsequent purchases areconverted to restorations.

testserver This should behave as in for testMode=normal.

Page 187: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Special notesHow to purchase one item several times on device?

• Following IAP design, there is no way to do this on S40 devices. Only when your application is live on Nokia Store, this can be doable in the version downloadedfrom Nokia Store.

Is it possible to test real money transactions?

• Not possible since whether you test on emulator or device, money transactions are bypassed in test mode. Once your application is published on Nokia Store,TEST_MODE.TXT will be removed and real money transactions can be processed.

How to save purchase status (trial or full version)?

• Use a RecordStore for storing and persisting a boolean value that indicates whether the full version has been purchased. This allows the MIDlet to launchcorrectly in either trial or full version mode.

• Try reading the DRM-protected content and catching the returned InputStream. Null result indicates that the content is still locked.

// Check whether user is granted DRM access right to IAP resources

InputStream is = m_pManager.getDRMResourceAsStream("/drm/data/ResourceId_" + m_strProductID + "/" +k_Certificate_FileName);

m_bIsTrialVersion = (is == null) ? true : false;

If using DRM protected content, how can you add new IAP items?

• Re-submit the newer version with new IAP items embedded

• Remember to restore the IAP items, which user has purchased in the old version

Page 188: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Game: First-time purchase (DRM in use, user signed out)

Page 189: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Game: Restoring a purchase (DRM in use, user signed out)

Page 190: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Game: Restoring a purchase (DRM in use, user signed in)

Page 191: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Game: Getting help

Page 192: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Publishing IAP application on Nokia Store• Select New Content Item

• Choose Java application

Page 193: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Publishing IAP application on Nokia Store• Select appropriate options

• Click Continue

Page 194: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Publishing IAP application on Nokia Store• Enter Content item name, which

appears on Nokia Publish site

• Check In-app purchase items checkbox

• Enter Display Name, which appears onNokia Store

• Enter Description, which describes theapplication on Nokia Store

• Choose suitable Category

• Check all suitable Categorization Tags

• Enter Keywords which are used whenconsumers search for applications onNokia Store

Page 195: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Publishing IAP application on Nokia Store• Select Global price point:

• Can be Free, 1/2/3 EUR (toleverage on Operator Billing)

• You should choose Free if yourapplication is T&B

• Enter Support website, where users canlook for help, instructions, tutorials,useful hints about your application:

• Must not contain any link toexternal websites

• Must not advertise aboutcompetitors apps and platforms

• Upload application Icon and Primaryscreen shot

• Click Create button

Page 196: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Publishing IAP application on Nokia Store• Select In-app purchases tab

• Enter In-app purchase name to use inNokia Publish site

• Enter IAP item metadata, which youwant to show to consumers:

• Display name

• Short Description

• Long Description

• Set Global price point. It can be 1/2/3EUR (to leverage on Operator Billing)

• Click Create button

Page 197: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Publishing IAP application on Nokia Store• In-app ID is the productID

to use in code

• Publication state is Notpublished means the IAPitem isn’t on Nokia Store.So you can’t retrieve itsinformation or purchase it

• Click Submit to QA buttonto have it tested

• QA Status is In Progressmeans QA is testing the IAPitem

• Once it’s passed QA, QAStatus will change toPassed, the IAP item will bepublished on Nokia Storethus Publication state willbe Published

Page 198: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Publishing IAP application on Nokia StoreBefore moving to this step, make sure you have these things done:

1. IAP item has passed QA and published on Nokia Store

2. Re-build your application with the In-app ID provided by Nokia Publish

• Choose Content Files tab

• Enter Content file name

• Check Use in-app purchase checkbox

• Upload JAD and JAR files

• Upload Additional documentation if needed:

• Flowchart

• Application Characteristic

• Click Upload & Continue button

Page 199: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Publishing IAP application on Nokia Store• Select all Devices that you’d like to distribute

• Click Next button

Page 200: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Publishing IAP application on Nokia Store• Select all Countries that you’d like to support

• Click Next button

• Select all Languages that you’d like to support

• Click Save button

Page 201: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Publishing IAP application on Nokia Store• Click Submit to QA button to have your application tested

• Follow the test report and keep fixing bugs until your application has been published onNokia Store

Page 202: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Using IAP to implement T&B

Page 203: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Steps to implement

Create a full game having all awesomefeatures

Add limitation to the game (number ofplayable levels, playing time...). Use a flagto control this mode (demo=true/false)

Implement IAP interface and process,which allows consumer to buy and unlock

full version

After having charged consumer, makesure to turn off demo mode and save

game status. Otherwise, it'll ask user tobuy again for the next time

Implement restoration policy forconsumers, who do master reset orfirmware upgrade. Display it in helpsection so that user can be aware

Page 204: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Business model

Reasons

Leverage on the big operator billing network globally

Utilize the huge volume of non-IAP devices

Maximize revenue in local market

Reasons

Leverage on the big operator billing network globally

Utilize the huge volume of non-IAP devices

Maximize revenue in local market

IAP Devices

Using IAP solution

IAP Devices

Using IAP solution

Local

Language: Vietnamese (game name, interface, help, information on Store)

Distribution: Vietnam

Global:

Language: English

Distribution: all countries

Non-IAP devices

Publishing as Paid App

Using third party T&B

Free download with In-app Advertising

Non-IAP devices

Publishing as Paid App

Using third party T&B

Free download with In-app Advertising

Page 205: Nokia Series 40 Full Touch Training - Dec 08 2012

Profiling

Page 206: Nokia Series 40 Full Touch Training - Dec 08 2012

Demo- Usb Logging

Page 207: Nokia Series 40 Full Touch Training - Dec 08 2012

VideoDecodecontrol

› If you are playing RTSPstreaming video, but the screenis turned off, you can savebattery power and network

… when hidden …

VideoDecodeControl vdc =(VideoDecodeControl)p.getControl("VideoDecodeControl") ;

vdc.setDecodeStatus(vdc.DECODE_OFF);…vdc.setDecodeStatus(vdc.DECODE_FULL);

Page 208: Nokia Series 40 Full Touch Training - Dec 08 2012

Porting to FullTouch» All Java ME apps should run on FT phone

– High-Level UI

– GOOD: Adapts automatically, including include touch-support and screen orientation

– BAD: Limited layout control and customization. New UI components (CategoryBar, etc.) don’t have to be used

– Low-Level UI

– New screen size & aspect ratio (use adaptive design and procedural graphics)

– Touch supported in Java ME since many years

» New APIs for Multitouch, Pinch, CategoryBar & Sensors

– Only work on FT phones

– Careful app design even keeps downwards compatibility

Page 209: Nokia Series 40 Full Touch Training - Dec 08 2012

PortingSe

ries

40

6th

Edit

ion

Touc

h &

Typ

e

Example: RpsGame

Full

Touc

h

Non-touch app with high-level UI (LCDUI):Automatically adapts to Touch

Page 210: Nokia Series 40 Full Touch Training - Dec 08 2012

Nokia Browser for Series 40» Unique proxy browser with server side JavaScript / Compression engine for Series 40

» Engine that made Series 40 Web Apps possible, because most Series 40 devices do not haveenough CPU/RAM to run a full WebKit based web browser

» Nokia Browser Proxy hosts the Web App client, and acts as a proxy between the Nokia BrowserClient and the Web App server, so can be described as ”Cloud-Assisted Web Runtime”

» Takes web app development for lower-end devices to a whole new level!

Page 211: Nokia Series 40 Full Touch Training - Dec 08 2012

» Nokia Browser main features:

› JavaScript runs on Nokia Browser Proxy server side

› Application content compressed before sending to the client

› CSS minimized, images compressed, partial HTML updates whenever possible

» Current Nokia Browser main constraints:

› HTML 4.01 with CSS 2.0 mobile profile (selected parts of CSS 3 also available)

› No device API access, no home screen widgets

Nokia Browser for Series 40

Page 212: Nokia Series 40 Full Touch Training - Dec 08 2012

XPressWeb app builder

http://forumnokia.adobeconnect.com/p7ss1wz7d2q/

http://xpresswebapps.nokia.com/

Introduction to the Xpress Web App Builder Webinar:

Page 213: Nokia Series 40 Full Touch Training - Dec 08 2012

Code Examples» Online

– http://bit.ly/JavaCodeExamples

» Included in Help

– Emulator → Help → MIDlet Samples

» Maps & Analytics

– C:\Nokia\devices\Nokia_SDK_2_0_Java\plugins

Page 214: Nokia Series 40 Full Touch Training - Dec 08 2012

Company Confidential

Thank You

[email protected]


Recommended