What is new in New Nokia AshaCao PhongDeveloper Tech Support ManagerAug 07, 2013
New Nokia Asha 501SUPER SMART POCKET POWER
• Fastlane: everything you need on one screen
• Standout colour and design
• Battery: 48 days of battery stand-by
• Price: 1,989,000 VND
Platforms
Developer Platform 2.0DP 1.1DP 1.06th Ed., FP16th Ed.6th Ed., Lite5th Ed., FP1 Nokia AshaSoftware
Platform 1.0Series 40
2 Mb 2 Mb 2 MbAsha 305, 306 Asha 308, 309, 310 Asha 311
2 Mb 2 Mb 4 Mb-- -- 1 GHz
CapacitiveMultipoint-Touch
ResistiveMultipoint-Touch (2)
CapacitiveMultipoint-Touch (5)
Jar SizeJava Heap
CPU
Screen
5 Mb*Asha 501
3 Mb--
CapacitiveMultipoint-Touch (3)
Development
Both free IDEs come with
extensive, generic Java ME support
on board.
Installation• Java JDK + JRE 7
−Update 17 (Later versions do not work – emulator: internal RMI registry port issues)
−32 bit version (also on 64 bit OS)−http://www.oracle.com/technetwork/java/javase/downloads/index.html
• Nokia Asha SDK (includes Nokia IDE)−https://www.developer.nokia.com/Develop/Java/Tools/
• Optional: NetBeans 7 (All Edition!)−http://netbeans.org/
• Optional: Oracle Java ME SDK−http://www.oracle.com/technetwork/java/javame/javamobile/downloa
d/sdk/index.html
!
NetBeans 7.3+
• NetBeans 7.x experience− Don’t choose Features on
Demand− Install Java SE + EE + ME
• Run NetBeans as Administrator once after Nokia SDK installation
− Integrates SDK docs
• Install additional plug-ins− Java ME SDK Tools− LWUIT Resource Editor− Java ME SDK Demos− Visual Mobile Designer
What does my phone support?
www.developer.nokia.com/Devices/
Versions
AshaSoftware Platform
Developer Platform
OS Version Phones
1.0 Asha Software Platform Asha 501
2.0.0 Series 40 Asha 305, 306, 308, 309, 310, 311
1.1.0 Series 40 Asha 200, 201, 302, 303
1.0.0 Series 40 Asha 202, 203; 301, C2-00, C2-02, C2-03, C2-05, C2-06, X2-02, X2-05
Series 40 6th Edition, FP 1 Asha 300, C3-01, X3-02
Series 40 6th Edition C2-01, C3-00, X2-00, X2-01, 6303i, 7230, 6350, 6750, 3720, ...
Series 40 6th Edition Lite C1-01, C1-02
Series 40 5th Edition, FP1 2690, 3208, 6600i, 2730, 2700, 6208, 6600, 8800, ...
Series 40 5th Edition, FP1 Lite 2220, 2720, 2320, 2330, 5000...
Series 40 5th Edition 3610, 6263, 6555, 7500, 6267
CLDC
MIDP 248 MSA
185 JTWI
75 File
82 BT
135 Medi
a
172 Web RPC
172 Web XML
177 SATSAAPDU
177 SATSACRYP
T
179 Location
184 3D
205 Messagin
g
211 Content
226 SVG
234 Camera
234 Audio3D
234 Musi
c
234 ImageE/P
234 Tune
r
238I18N
256 Sens
or
Nokia UI
IAP
Asha1.0
1.1 2.1 - - 1.0 1.1 1.2 1.0 1.0 - 1.0 1.0.1 1.1 2.0 1.0.1 1.1 1.1 - - 1.1 1.1 1.6 1.2 1.7 beta
2.0.0 1.1 - 1.0 1.0 1.0 1.1 1.1 - - - 1.6 2.0
1.1.0 - - - - - 1.1 1.0
1.0.0 - - - - - 1.1b -
S40 6th,FP1
- - - - - 1.1b -
S40 6th
√ - √ - - - - 1.1 -
S406th Lite
- √ - - - - - - - - - -
S40 5th FP1
√ - 1.1 - √ - 1.0 1.0 - - - - -
S40 5th FP1
L
- √ - - - - - - - - - - - - - - -
S40 5th
√ - 1.1 1.0 1.0 - 1.1 - √ - 1.0 1.0 - - - - -
SDKs
www.developer.nokia.com/Develop/Java/Tools/Series_40_platform_SDKs/
1 emulator per SDK.Install multiple SDKs for
more emulators.
www.developer.nokia.com/Develop/asha/java/downloads.xhtml
Asha SDK 1.0 - Emulator
Simulate device UX
Asha SDK 1.0 - Emulator
Asha SDK 1.0 - Emulator
Asha SDK 1.0 - Emulator
Asha SDK 1.0 - Emulator• Offline Javadocs• Helpful Code examples
Asha SDK 1.0 - Emulator
Nokia IDE for Java ME
• Device SDK Selector
Nokia IDE for Java ME
• Download Code Examples
Demo- Asha SDK Emulator- Nokia IDE for Java ME
New Asha UXde
velo
per.n
okia
.com
/Des
ign/
Hardware Keys
Back Button
Demo- New Asha UX
User Interface Layout
Screen Sizes
Touch-and-type Full touch Nokia Asha
UI Strategies
Custom UI on Canvas LCDUI High-Level UI LWUIT Library
High Level UI
Display
CanvasScreen
TextBox FormList Alert
ChoiceGroup
DateField
TextField Gauge
ImageItem
StringItemChoice (Interface)
ItemSpacer CustomItem
Command
Ticker Graphics
Displayable
Low Level UIDraw the GUI yourself, own event handling. Used for
games and bigger commercial applications.
Completely pre-defined screen layouts
High Level UIAppearance based on default phone UI
design, can not be influenced.
Arrange predefined controls on a screen.
LWUITUI Library draws UI directly using low level
UI drawing methods.
High Level UI
Display
CanvasScreen
TextBox FormList Alert
ChoiceGroup
DateField
TextField Gauge
ImageItem
StringItemChoice (Interface)
One Display instance / MIDlet
Methods for drawing to a
canvas
Available in all sub-classes of
Displayable
ItemSpacer CustomItem
Command
Ticker Graphics
Displayable LWUIT
High Level UI: Forms
Individual items, automatically arranged below each other. The
appearance depends on the phone.
WTK Emulator Nokia 7710 Emulator
LWUIT
• LightWeight User Interface Toolkit− Inspired by Swing, but designed for constrained
devices− Can be added to any Java ME application
(embedded .jar)− Drawing done in Java source code, without native
peer rendering• Optimized version for Nokia!• Features (excerpt):
− Layouts− Themes, fonts− Animations & Transitions− 3D / SVG integration (optional)− Internationalization
Remote Device Access
• Enabling testing on real devices
• Free for Nokia Developer users
• Go to RDA: http://www.developer.nokia.com/Devices/Remote_device_access/
• Watch introductory video: http://www.developer.nokia.com/Develop/Java/Videos/
• http://www.youtube.com/watch?v=F1odix8k_fg
Internationalization
• JSR-238−Format data for locales−Locale-aware string comparison−Translation: manage app & device resources
Formatter
• Locale-specific data−dates, times, numbers,
percentages, currency• Generic message formatting
−placeholders {n} / {nn}
Asha EmulatorSupported locales
enkn-IN
taur
// Text definitionsString txtCurrency = "Currency: {0}"; // [...]String txtTime = "Time: {0}";
// No parameter -> would use current locale (microedition.locale)Formatter format = new Formatter("kn-IN");frmMain.append(Formatter.formatMessage(txtCurrency, new String[] {format.formatCurrency(currency)}));frmMain.append(Formatter.formatMessage(txtTime, new String[] {format.formatDateTime(dateTime, Formatter.TIME_LONG)}));
Example: InternationalDemo
Phone Settings
• Current state & change listener subscriptions−Flight mode−Data connection−Background data connection−Roaming data connection−Vibrator mode−Silent mode
Setting Detection• Retrieve setting
int settingState = Setting.getSetting(Setting.SETTING_FLIGHT_MODE);
ONOFFINVALIDDENYASKACCEPTWIFIONLY
SETTING_FLIGHT_MODESETTING_DATA_CONNECTIONSETTING_BACKGROUND_DATA_CONNECTIONSETTING_ROAMING_DATA_CONNECTIONSETTING_VIBRATORSETTING_SILENT
Example: PhoneSettings
State changes available via listener
Network State• Monitor state of
−Network (home / roaming)−SIM−WLAN
Network State Detection
• Retrieve status for SIM cardExample: PhoneSettings
int networkState = NetworkState.getState(simCard);
NETWORK_STATE_NO_NETWORKNETWORK_STATE_HOMENETWORK_STATE_ROAMING
01
State changes available via listener
SIM State Detection
• Retrieve status for SIM cardExample: PhoneSettings
int simState = SIMState.getState(simCard);
SIM_STATE_READYSIM_STATE_NOT_READYSIM_STATE_NO_SIM
01
State changes available via listener
Network State Detection
• Retrieve status for WLANExample: PhoneSettings
int wlanState = WLANState.getState();
WLAN_STATE_CONNECTEDWLAN_STATE_NOT_CONNECTED
State changes available via listener
Demo- PhoneSettings
File Selection• Native file browser UI to list + select
files− Images & documents for viewing /
editing−Files for uploading to web service & as
message attachments−Audio or video clips for playback
• Blocks calling thread−Don’t use in event handling thread
(e.g., command action)
SDK Example: FileSelectExample
Launch File Dialog• Launch file selection (in own thread)
Example: SimpleFileSelect
// Launch file selection dialogFileSelectDetail[] arrSelectedFiles = FileSelect.launch(
FileSelect.FILE_SYSTEM_ALL, FileSelect.MEDIA_TYPE_ALL, false);
FILE_SYSTEM_ALL FILE_SYSTEM_EXTERNALFILE_SYSTEM_INTERNAL… or specific start folder, e.g.,System.getProperty("fileconn.dir.photos")
MEDIA_TYPE_ALLMEDIA_TYPE_APPLICATIONMEDIA_TYPE_AUDIOMEDIA_TYPE_PICTUREMEDIA_TYPE_VIDEO
false: single-filetrue: multi-file
File Selection Results• Print metadata of selected file(s)
if (arrSelectedFiles != null) {// Show file meta data on the screenfor (int i = 0; i < arrSelectedFiles.length; i++) {
// Display name = file namefrmMain.append("Display name: " + arrSelectedFiles[i].displayName);// MIME type, e.g., video/mp4 or image/pngfrmMain.append("MIME type: " + arrSelectedFiles[i].mimeType);// Size of the selected file in bytesfrmMain.append("Size: " + arrSelectedFiles[i].size);// Full path to the filefrmMain.append("URL: " + arrSelectedFiles[i].url);
}}
Example: SimpleFileSelect
Demo- FileSelect
Notification API
• Push messages to user’s phones
−Also when app is not running
−Notification banner−Caches up to 5 messages
per app (for up to 14 days)−Payload ≤ 1.5 kB
SDK Example: NNAClientExample
Notifications – Sign Up• Register new service ID
−Creates service secret−https://account.nnapi.ovi.com
/cm/Web/services.jsp
• Environments−Sandbox for testing−Production available after 5
days−Separate server for China
Notifications Flow – Client
Do you want to receive service X
related push notifications?
App needs to ask user for consent
App registers with online push
service
App retrieves client-specific notification ID, sends to own
notifications web service
1 2
Your own custom web service, manages
notification IDs from subscribed clients
Notifications Flow – Push
User gets push notification
Notification bar shows details
4
3 Sandbox testing in Developer Console: push messages without need for own web service
Notifications Flow – Retrieve
User launches app (e.g., through notification bar).
App registers online.
App gets cached push
notifications.
Note: user can turn off
notifications for apps.
EnvironmentSelector
• App for device / emulator−Swich between push servers
C:\Nokia\Examples\Nokia_Asha_SDK_1_0\NNAClientExample\EnvironmentSelector
Client Implementation• Open session
−1 session / app−Keep open for lifetime of app
• Register app
−Callback: stateChanged(NotificationState.STATE_ONLINE)
NotificationSession session = NotificationSessionFactory.openSession(main, // The MIDlet instance"example.com", // Service ID (Deprecated, but still has to be provided)"com.example", // Application IDthis); // NotificationSessionListener
session.registerApplication();
Developer Console
Client Implementation• Get Notification ID for this phone
−Callback: infoReceived(NotificationInfo info)−Send this to your web service
• Receive messages
session.getNotificationInformation();
public void messageReceived(NotificationMessage message) {// Get data as stringString msgData = message.getPayload().getData();
}
Notification Service
• Push via REST API (HTTPS)−From own web service−To Nokia Notification Server
www.developer.nokia.com/Resources/Library/Java/#!developers-guides/nokia-notifications/nokia-notifications-service-api-rest-api.html
Push Messages• Messages
−App running?−No info banner, directly delivered
−Not running?−≤ 5 messages cached−Customizable: info banner, alert
• Delivery confirmations−Not part of Nokia service−Own app can contact own web service
Message Properties
Checked: delivered also when app is NOT running
Checked: user is alerted about new message
Notification title shown to the user
Not used / shown / accessible
MIME type of payload. Default: application/octet-stream
Not used. App icon shown instead
Maximum cache lifetime (≤ 14 days)
Raw payload to send to the app
Notification ID of the client to push to
Demo- NNAClientExample
Tuner• AM / FM radio
−Tuning−Seeking−Squelch−Stereo mode−Signal strength query−Presets
• Advanced Multimedia Supplements (JSR-234)
SDK Example: AMMSTuner
Seek Radio Channels• Initialize radio
• Start playing
Example: Radio// Create generic Java ME player, with the specific radio URLplayer = Manager.createPlayer("capture://radio");// Construct playerplayer.realize();// Get controller to control radio (seeking, specifying properties, etc.)tuner = (TunerControl) player.getControl("javax.microedition.amms.control.tuner.TunerControl");
// Minimum frequency in FM band to start searchcurFrequency = tuner.getMinFreq(TunerControl.MODULATION_FM);// Start playingplayer.start(); // Start search for the first stationcurFrequency = tuner.seek(curFrequency, TunerControl.MODULATION_FM, true);
Demo- AMMSTuner (Device)
Touch Gestures• Use in: Canvas-/CustomItem-based classes
−Optional: combine with Frame Animator API (kinetic scrolling)
• Available since Touch & Type−Tap: touch + release−Double Tap: touch + release + touch + release (new in Asha
Platform)−Long Press (& repeated): touch + hold−Drag: touch + drag−Drop: touch + drag + touch down (“stop”) + release−Flick: touch + drag + release while dragging−Pinch: 2x touch + 2x drag + 2x touch down (“stop”) + 2x
release (new in Full Touch)
Gesture Components
App
Java Runtime
GestureAction
RegistersRegisters
GestureListener
GestureInteractive
Zone
GestureRegistration
Manager
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
Using: Gestures• Handling gestures
−Executed in UI thread−Lengthy operations (scaling image, etc.) → own thread!
−Parameters only valid during call (instances reused for next call-back)
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;
}}
Demo- Gesture
Image Scaler APIPros:• Simple usage• Fast performance• Resolve heap size
bottleneck
Cons:• Upscaling is not
completely supported due to uncontrollable memory use
Image Scaler API1. import com.nokia.mid.imagescale.*
2. Construct a new ImageScaler object with source and destination path of the image:
3. Apply for JPEG files: use the ImageScaler.setJpegQuality method for specifiying output quality of the JPEG image:
4. Use the ImageScaler.scaleImage method for downscaling image in two ways:
//Construct a new ImageScaler object to downscale a JPEG image on the deviceImageScaler is = new ImageScaler("file:///Phone/big.jpg", "file:///Phone/small.jpg"); // PNG file is OK
//Set image quality for the JPEG imageis.setJpegQuality(70);
//Set the downscaled image’s file size to be less than or equal to 100kbis.scaleImage(100);
//Set the downscaled image’s dimensions to 320x480px, and ignore the source image’s aspect ratiois.scaleImage(320, 480, false);
Image Processing – AMMS (JSR-234)• Convert image format:
png, jpg…• Image transformation:
Crop Zoom Mirror Flip Stretch Rotate
• Image filters: Monochrome Negative Emboss Sepia Solarize Redeyereduction
o interface javax.microedition.amms.control.imageeffect.ImageEffectControlo interface javax.microedition.amms.control.imageeffect.ImageTonalityControlo interface javax.microedition.amms.control.imageeffect.ImageTransformControlo interface javax.microedition.amms.control.imageeffect.OverlayControlo interface javax.microedition.amms.control.imageeffect.WhiteBalanceControl
Image Processing – AMMS (JSR-234)
MediaProcessor mp = GlobalManager.createMediaProcessor("image/jpeg"); InputStream inputStream = ... // create a InputStream that contains the source image OutputStreamoutputStream = ... // create a OutputStream that will receive the resulting image
mp.setInput(inputStream); mp.setOutput(outputStream);
// Define effects to be applied during processing ImageEffectControl imageEffect = (ImageEffectControl)mp.getControl("javax.microedition.amms.control.imageeffect.ImageEffectControl"); imageEffect.setPreset("monochrome");
// Set output format ImageFormatControl fc = (ImageFormatControl)mp.getControl("javax.microedition.amms.control.ImageFormatControl");fc.setFormat("image/jpeg"); fc.setParameter("quality", 80);
// Do the actual processing. If you do not want to use a blocking call, // use start() and MediaProcessorListener. mp.complete();
Apply monochrome effect
Demo- ImageScaler- Imaging
Contact APIDiscover and receive changes to the device’s contacts in the phonebook. MIDlets can use the Contact API to discover when:
• Contacts are added to the phonebook
• Contacts are deleted from the phonebook
• Contacts are modified, i.e. the fields of the contacts are changed, in the phonebook
Sensors
• JSR 256 - Sensor API− Generic: designed also for
temperature, blood pressure, etc.
• 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
Double Tap Sensor
http://www.developer.nokia.com/Resources/Library/Java/_zip/GUID-F031C633-5F4E-441E-A863-CE4E28A9CD55/appendixE.html
Finding Sensors
Application SensorManager SensorInfo Connector
findSensors(quantity, contextType)
return SensorInfo[]
getUrl()
return URL
Connector.open(URL)
return SensorConnection
Sensor Values
• Modes− Synchronous
− Poll sensor− Example: accelerometer in game loop
− Asynchronous− DataListener callbacks− Example: phone charger plugged in
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
Demo- Racer- Double Tap Soccer (Device)
THANK YOU!Nokia Vietnam – Developers Experience: https://www.facebook.com/groups/viet.nok.dev/