What is new in
New Nokia Asha
Cao Phong
Developer Tech Support Manager
Aug 07, 2013
New NokiaAsha 501
SUPER SMART POCKET POWER
• Fastlane: everything you need
on one screen
• Standout colour and design
• Ba...
Platforms
Developer Platform 2.0DP 1.1DP 1.06th Ed., FP16th Ed.6th Ed., Lite5th Ed., FP1 Nokia Asha
Software
Platform 1.0
...
2 Mb 2 Mb 2 Mb
Asha 305, 306 Asha 308, 309, 310 Asha 311
2 Mb 2 Mb 4 Mb
-- -- 1 GHz
Capacitive
Multipoint-Touch
Resistive
...
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 ...
NetBeans 7.3+
• NetBeans 7.x experience
− Don’t choose Features on
Demand
− Install Java SE + EE + ME
• Run NetBeans as
Ad...
What does my phone support?
www.developer.nokia.com/Devices/
Versions
Asha
Software
Platform
Developer
Platform
OS Version Phones
1.0 Asha Software Platform Asha 501
2.0.0 Series 40 A...
CLD
C
MIDP 248
MSA
185
JTWI
75
File
82
BT
135
Medi
a
172
Web
RPC
172
Web
XML
177
SAT
SAA
PDU
177
SAT
SAC
RYP
T
179
Loca
ti...
SDKs
www.developer.nokia.com/Develop/Java/Tools/Series_40_platform_SDKs/
1 emulator per SDK.
Install multiple SDKs for
mor...
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 UXdeveloper.nokia.com/Design/
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...
High Level UI
Display
CanvasScreen
TextBox FormList Alert
ChoiceGroup
DateField
TextField Gauge
ImageItem
StringItemChoice...
High Level UI: Forms
Individual items, automatically
arranged below each other. The
appearance depends on the
phone.
WTK E...
LWUIT
• LightWeight User Interface Toolkit
− Inspired by Swing, but designed for constrained
devices
− Can be added to any...
Remote Device Access
• Enabling testing on real devices
• Free for Nokia Developer users
• Go to RDA:
http://www.developer...
Internationalization
• JSR-238
−Format data for locales
−Locale-aware string comparison
−Translation: manage app & device ...
Formatter
• Locale-specific data
−dates, times, numbers,
percentages, currency
• Generic message formatting
−placeholders ...
Phone Settings
• Current state & change listener subscriptions
−Flight mode
−Data connection
−Background data connection
−...
Setting Detection
• Retrieve setting
int settingState = Setting.getSetting(Setting.SETTING_FLIGHT_MODE);
ON
OFF
INVALID
DE...
Network State
• Monitor state of
−Network (home / roaming)
−SIM
−WLAN
Network State Detection
• Retrieve status for SIM card
Example: PhoneSettings
int networkState = NetworkState.getState(sim...
SIM State Detection
• Retrieve status for SIM card
Example: PhoneSettings
int simState = SIMState.getState(simCard);
SIM_S...
Network State Detection
• Retrieve status for WLAN
Example: PhoneSettings
int wlanState = WLANState.getState();
WLAN_STATE...
Demo
- PhoneSettings
File Selection
• Native file browser UI to list + select
files
−Images & documents for viewing /
editing
−Files for upload...
Launch File Dialog
• Launch file selection (in own thread)
Example:
SimpleFileSelect
// Launch file selection dialog
FileS...
File Selection Results
• Print metadata of selected file(s)
if (arrSelectedFiles != null) {
// Show file meta data on the ...
Demo
- FileSelect
Notification API
• Push messages to user’s
phones
−Also when app is not
running
−Notification banner
−Caches up to 5 messa...
Notifications – Sign Up
• Register new service ID
−Creates service secret
−https://account.nnapi.ovi.com
/cm/Web/services....
Notifications Flow – Client
Do you want
to receive
service X
related push
notifications?
App needs to ask
user for consent...
Notifications Flow – Push
User gets push
notification
Notification bar
shows details
4
3 Sandbox testing in Developer Cons...
Notifications Flow – Retrieve
User launches
app (e.g., through
notification bar).
App registers
online.
App gets cached
pu...
EnvironmentSelector
• App for device / emulator
−Swich between push servers
C:NokiaExamplesNokia_Asha_SDK_1_0NNAClientExam...
Client Implementation
• Open session
−1 session / app
−Keep open for lifetime of app
• Register app
−Callback:
stateChange...
Client Implementation
• Get Notification ID for this phone
−Callback: infoReceived(NotificationInfo info)
−Send this to yo...
Notification Service
• Push via REST API (HTTPS)
−From own web service
−To Nokia Notification Server
www.developer.nokia.c...
Push Messages
• Messages
−App running?
−No info banner, directly delivered
−Not running?
−≤ 5 messages cached
−Customizabl...
Message Properties
Checked: delivered also when app is NOT running
Checked: user is alerted about new message
Notification...
Demo
- NNAClientExample
Tuner
• AM / FM radio
−Tuning
−Seeking
−Squelch
−Stereo mode
−Signal strength query
−Presets
• Advanced Multimedia Supplem...
Seek Radio Channels
• Initialize radio
• Start playing
Example: Radio
// Create generic Java ME player, with the specific ...
Demo
- AMMSTuner (Device)
Touch Gestures
• Use in: Canvas-/CustomItem-based classes
−Optional: combine with Frame Animator API (kinetic scrolling)
•...
Gesture Components
App
Java Runtime
GestureAction
RegistersRegisters
Gesture
Listener
Gesture
Interactive
Zone
Gesture
Reg...
Using: Gestures
• Register as gesture listener
−Zone: reacts to 1+ specified gestures
−Whole screen or rectangular area
−O...
Using: Gestures
• Handling gestures
−Executed in UI thread
−Lengthy operations (scaling image, etc.) → own thread!
−Parame...
Demo
- Gesture
Image Scaler API
Pros:
• Simple usage
• Fast performance
• Resolve heap size
bottleneck
Cons:
• Upscaling is not
completel...
Image Scaler API
1. import com.nokia.mid.imagescale.*
2. Construct a new ImageScaler object with source and destination pa...
Image Processing – AMMS (JSR-234)
• Convert image format:
png, jpg…
• Image transformation:
 Crop
 Zoom
 Mirror
 Flip
...
Image Processing – AMMS (JSR-234)
MediaProcessor mp = GlobalManager.createMediaProcessor("image/jpeg");
InputStream inputS...
Demo
- ImageScaler
- Imaging
Contact API
Discover and receive changes to the device’s contacts in the phonebook. MIDlets can use
the Contact API to dis...
Sensors
• JSR 256 - Sensor API
− Generic: designed also for
temperature, blood pressure, etc.
• Currently supported
− Batt...
Double Tap Sensor
http://www.developer.nokia.com/Resources/Library/Java/_zip/GUID-F031C633-5F4E-441E-A863-
CE4E28A9CD55/ap...
Finding Sensors
Application SensorManager SensorInfo Connector
findSensors(quantity,
contextType)
return SensorInfo[]
getU...
Sensor Values
• Modes
− Synchronous
− Poll sensor
− Example: accelerometer in game loop
− Asynchronous
− DataListener call...
Using: Sensors
• Establish sensor connection
• Check data in game loop
// Find all acceleration sensors, the contextType i...
Demo
- Racer
- Double Tap Soccer (Device)
THANK YOU!
Nokia Vietnam – Developers Experience:
https://www.facebook.com/groups/viet.nok.dev/
Day1_1 what is new in new nokia asha
Day1_1 what is new in new nokia asha
Day1_1 what is new in new nokia asha
Upcoming SlideShare
Loading in …5
×

Day1_1 what is new in new nokia asha

1,891
-1

Published on

http://winstore.vn

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,891
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Day1_1 what is new in new nokia asha

  1. 1. What is new in New Nokia Asha Cao Phong Developer Tech Support Manager Aug 07, 2013
  2. 2. New NokiaAsha 501 SUPER 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
  3. 3. Platforms Developer Platform 2.0DP 1.1DP 1.06th Ed., FP16th Ed.6th Ed., Lite5th Ed., FP1 Nokia Asha Software Platform 1.0 Series 40
  4. 4. 2 Mb 2 Mb 2 Mb Asha 305, 306 Asha 308, 309, 310 Asha 311 2 Mb 2 Mb 4 Mb -- -- 1 GHz Capacitive Multipoint-Touch Resistive Multipoint-Touch (2) Capacitive Multipoint-Touch (5) Jar Size Java Heap CPU Screen 5 Mb* Asha 501 3 Mb -- Capacitive Multipoint-Touch (3)
  5. 5. Development Both free IDEs come with extensive, generic Java ME support on board.
  6. 6. 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 !
  7. 7. 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
  8. 8. What does my phone support? www.developer.nokia.com/Devices/
  9. 9. Versions Asha Software 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
  10. 10. CLD C MIDP 248 MSA 185 JTWI 75 File 82 BT 135 Medi a 172 Web RPC 172 Web XML 177 SAT SAA PDU 177 SAT SAC RYP T 179 Loca tion 184 3D 205 Mess agin g 211 Cont ent 226 SVG 234 Cam era 234 Audi o3D 234 Musi c 234 Imag eE/P 234 Tune r 238 I18N 256 Sens or Noki a UI IAP Asha 1.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 - S40 6th 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 - - - - -
  11. 11. 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
  12. 12. Asha SDK 1.0 - Emulator Simulate device UX
  13. 13. Asha SDK 1.0 - Emulator
  14. 14. Asha SDK 1.0 - Emulator
  15. 15. Asha SDK 1.0 - Emulator
  16. 16. Asha SDK 1.0 - Emulator • Offline Javadocs • Helpful Code examples
  17. 17. Asha SDK 1.0 - Emulator
  18. 18. Nokia IDE for Java ME • Device SDK Selector
  19. 19. Nokia IDE for Java ME • Download Code Examples
  20. 20. Demo - Asha SDK Emulator - Nokia IDE for Java ME
  21. 21. New Asha UXdeveloper.nokia.com/Design/
  22. 22. Hardware Keys
  23. 23. Back Button
  24. 24. Demo - New Asha UX
  25. 25. User Interface Layout
  26. 26. Screen Sizes Touch-and-type Full touch Nokia Asha
  27. 27. UI Strategies Custom UI on Canvas LCDUI High-Level UI LWUIT Library
  28. 28. High Level UI Display CanvasScreen TextBox FormList Alert ChoiceGroup DateField TextField Gauge ImageItem StringItemChoice (Interface) ItemSpacer CustomItem Command Ticker Graphics Displayable Low Level UI Draw the GUI yourself, own event handling. Used for games and bigger commercial applications. Completely pre-defined screen layouts High Level UI Appearance based on default phone UI design, can not be influenced. Arrange predefined controls on a screen. LWUIT UI Library draws UI directly using low level UI drawing methods.
  29. 29. 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
  30. 30. High Level UI: Forms Individual items, automatically arranged below each other. The appearance depends on the phone. WTK Emulator Nokia 7710 Emulator
  31. 31. 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
  32. 32. 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
  33. 33. Internationalization • JSR-238 −Format data for locales −Locale-aware string comparison −Translation: manage app & device resources
  34. 34. Formatter • Locale-specific data −dates, times, numbers, percentages, currency • Generic message formatting −placeholders {n} / {nn} Asha Emulator Supported locales en kn-IN ta ur // Text definitions String 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
  35. 35. Phone Settings • Current state & change listener subscriptions −Flight mode −Data connection −Background data connection −Roaming data connection −Vibrator mode −Silent mode
  36. 36. Setting Detection • Retrieve setting int settingState = Setting.getSetting(Setting.SETTING_FLIGHT_MODE); ON OFF INVALID DENY ASK ACCEPT WIFIONLY SETTING_FLIGHT_MODE SETTING_DATA_CONNECTION SETTING_BACKGROUND_DATA_CONNECTI ON SETTING_ROAMING_DATA_CONNECTION SETTING_VIBRATOR SETTING_SILENT Example: PhoneSettings State changes available via listener
  37. 37. Network State • Monitor state of −Network (home / roaming) −SIM −WLAN
  38. 38. Network State Detection • Retrieve status for SIM card Example: PhoneSettings int networkState = NetworkState.getState(simCard); NETWORK_STATE_NO_NETWOR K NETWORK_STATE_HOME NETWORK_STATE_ROAMING 0 1 State changes available via listener
  39. 39. SIM State Detection • Retrieve status for SIM card Example: PhoneSettings int simState = SIMState.getState(simCard); SIM_STATE_READY SIM_STATE_NOT_READY SIM_STATE_NO_SIM 0 1 State changes available via listener
  40. 40. Network State Detection • Retrieve status for WLAN Example: PhoneSettings int wlanState = WLANState.getState(); WLAN_STATE_CONNECTED WLAN_STATE_NOT_CONNECTED State changes available via listener
  41. 41. Demo - PhoneSettings
  42. 42. 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
  43. 43. Launch File Dialog • Launch file selection (in own thread) Example: SimpleFileSelect // Launch file selection dialog FileSelectDetail[] arrSelectedFiles = FileSelect.launch( FileSelect.FILE_SYSTEM_ALL, FileSelect.MEDIA_TYPE_ALL, false); FILE_SYSTEM_ALL FILE_SYSTEM_EXTERNAL FILE_SYSTEM_INTERNAL … or specific start folder, e.g., System.getProperty("fileconn.dir.photos") MEDIA_TYPE_ALL MEDIA_TYPE_APPLICATION MEDIA_TYPE_AUDIO MEDIA_TYPE_PICTURE MEDIA_TYPE_VIDEO false: single-file true: multi-file
  44. 44. File Selection Results • Print metadata of selected file(s) if (arrSelectedFiles != null) { // Show file meta data on the screen for (int i = 0; i < arrSelectedFiles.length; i++) { // Display name = file name frmMain.append("Display name: " + arrSelectedFiles[i].displayName); // MIME type, e.g., video/mp4 or image/png frmMain.append("MIME type: " + arrSelectedFiles[i].mimeType); // Size of the selected file in bytes frmMain.append("Size: " + arrSelectedFiles[i].size); // Full path to the file frmMain.append("URL: " + arrSelectedFiles[i].url); } } Example: SimpleFileSelect
  45. 45. Demo - FileSelect
  46. 46. 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
  47. 47. 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
  48. 48. 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
  49. 49. 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
  50. 50. 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.
  51. 51. EnvironmentSelector • App for device / emulator −Swich between push servers C:NokiaExamplesNokia_Asha_SDK_1_0NNAClientExampleEnvironmentSelector
  52. 52. 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 ID this); // NotificationSessionListener session.registerApplication(); Developer Console
  53. 53. 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 string String msgData = message.getPayload().getData(); }
  54. 54. 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
  55. 55. 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
  56. 56. 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
  57. 57. Demo - NNAClientExample
  58. 58. Tuner • AM / FM radio −Tuning −Seeking −Squelch −Stereo mode −Signal strength query −Presets • Advanced Multimedia Supplements (JSR-234) SDK Example: AMMSTuner
  59. 59. Seek Radio Channels • Initialize radio • Start playing Example: Radio // Create generic Java ME player, with the specific radio URL player = Manager.createPlayer("capture://radio"); // Construct player player.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 search curFrequency = tuner.getMinFreq(TunerControl.MODULATION_FM); // Start playing player.start(); // Start search for the first station curFrequency = tuner.seek(curFrequency, TunerControl.MODULATION_FM, true);
  60. 60. Demo - AMMSTuner (Device)
  61. 61. 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)
  62. 62. Gesture Components App Java Runtime GestureAction RegistersRegisters Gesture Listener Gesture Interactive Zone Gesture Registration Manager
  63. 63. 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 listener GestureRegistrationManager.setListener(this, this); // Register for pinch events in the whole canvas area gestureZone = new GestureInteractiveZone(GestureInteractiveZone.GESTURE_PINCH); GestureRegistrationManager.register(this, gestureZone); } Example: PaintApp
  64. 64. 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 detected curPinchDistance = gestureEvent.getPinchDistanceCurrent(); break; case GestureInteractiveZone.GESTURE_RECOGNITION_START: /* ... */ break; case GestureInteractiveZone.GESTURE_RECOGNITION_END: /* ... */ break; } }
  65. 65. Demo - Gesture
  66. 66. Image Scaler API Pros: • Simple usage • Fast performance • Resolve heap size bottleneck Cons: • Upscaling is not completely supported due to uncontrollable memory use
  67. 67. Image Scaler API 1. 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 device ImageScaler is = new ImageScaler("file:///Phone/big.jpg", "file:///Phone/small.jpg"); // PNG file is OK //Set image quality for the JPEG image is.setJpegQuality(70); //Set the downscaled image’s file size to be less than or equal to 100kb is.scaleImage(100); //Set the downscaled image’s dimensions to 320x480px, and ignore the source image’s aspect ratio is.scaleImage(320, 480, false);
  68. 68. 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.ImageEffectControl o interface javax.microedition.amms.control.imageeffect.ImageTonalityControl o interface javax.microedition.amms.control.imageeffect.ImageTransformControl o interface javax.microedition.amms.control.imageeffect.OverlayControl o interface javax.microedition.amms.control.imageeffect.WhiteBalanceControl
  69. 69. Image Processing – AMMS (JSR-234) MediaProcessor mp = GlobalManager.createMediaProcessor("image/jpeg"); InputStream inputStream = ... // create a InputStream that contains the source image OutputStream outputStream = ... // 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
  70. 70. Demo - ImageScaler - Imaging
  71. 71. Contact API Discover 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
  72. 72. 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
  73. 73. Double Tap Sensor http://www.developer.nokia.com/Resources/Library/Java/_zip/GUID-F031C633-5F4E-441E-A863- CE4E28A9CD55/appendixE.html
  74. 74. Finding Sensors Application SensorManager SensorInfo Connector findSensors(quantity, contextType) return SensorInfo[] getUrl() return URL Connector.open(URL) return SensorConnection
  75. 75. Sensor Values • Modes − Synchronous − Poll sensor − Example: accelerometer in game loop − Asynchronous − DataListener callbacks − Example: phone charger plugged in
  76. 76. Using: Sensors • Establish sensor connection • Check data in game loop // Find all acceleration sensors, the contextType is left undefined SensorInfo[] sensorInfos = SensorManager.findSensors("acceleration", null); // Find an acceleration sensor that returns double values for (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 axis Data[] data = accSensor.getData(1); speedX = -data[0].getDoubleValues()[0]; // data[0] => x-axis speedY = data[1].getDoubleValues()[0]; // data[1] => y-axis Example: MovingBall
  77. 77. Demo - Racer - Double Tap Soccer (Device)
  78. 78. THANK YOU! Nokia Vietnam – Developers Experience: https://www.facebook.com/groups/viet.nok.dev/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×