SlideShare uma empresa Scribd logo
ADVANCED EXAMPLES OF SENSOR
USAGE IN JAVA ME ON SERIES 40


Attila Csipa [@achipa]
Technology Wizard, Nokia

 1     © 2012 Nokia Advanced examples of sensor usage in Java ME on Series 40 v1.2 February 19, 2013 Attila Csipa
CONTENTS
• Introduction
     – Platforms & Versions
• Sensors
     –   Physical vs virtual
     –   JSR-256
     –   Measurables
     –   Accelerometers
     –   Usage
     –   UI considerations
     –   Performance
     –   App Compatibility
• Resources



 2          © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
PLATFORMS
API Differences: bit.ly/S40Apis




5th Ed., FP1    6th Ed., Lite            6th Ed.              6th Ed., FP1                  DP 1.0                       DP 1.1   Developer Platform 2.0




          http://www.developer.nokia.com/Devices/Device_specifications/Comparison.xhtml?dev=Asha_306,Nokia_Asha_309,Asha_311


  3            © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
DP 2.0 – NEW APIS

         Full touch                                  Sensors &                                        Multipoint
              UI                                     Orientation                                      Touch APIs

         Gestures:                                       Virtual
                                                                                                                       ...
          Pinch                                         Keyboard

4   © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
SENSORS
    Etymology
    Originated 1925–30 from sense + -or.

    Noun
    sensor (plural sensors)
    A device or organ that detects certain external stimuli and responds in a
    distinctive manner.


5         © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
SENSORS: PHYSICAL VS VIRTUAL
• Physical sensors (physical values, g or m/s, mbar, etc)
     – Acceleration
     – Light
     – ...
• Virtual sensors (combined or interpreted values, %, enum-s)
    – Battery level
    – Orientation
    –…
 6      © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
SENSORS: JSR-256
                                                                               JSR page at Nokia Developer JSR docs

• JSR 256 Sensor API
    – Generic: designed also for temperature, blood pressure, etc.
    – Support on Series40 from DP2.0 (Asha Full Touch)
    – Also available on Symbian (from S60 5th edition onwards)
• Two packages
        javax.microedition.sensor (read information)
        javax.microedition.sensor.control (settings, start/stop)
7      © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
SENSORS: WHAT TO LOOK FOR
• 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


8      © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
SENSORS: ACCELEROMETERS ARE COOL
• Enrich user interaction
    – Doesn’t suffer from finger size limits
    – Doesn’t suffer from screen size limits
    – Doesn’t interfere with what the user sees on the screen
    – Natural interaction (language/culture independent)
• Ideal for games!


9      © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
SENSORS: UNDERSTANDING ACCELEROMETERS
• Acceleration is CHANGE of the speed vector
• Standstill normalized value is 1.0, why? GRAVITY
• Nitpick - accelerometers measure translation not rotation
• Rotation can still be measured indirectly (we measure
 gravity vector hopping from one axis to the other)



10    © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
Example:
SENSORS: API AVAILABILITY                                                                                                  Racer, aMaze



• No System property for the API version?
     – Check Class availability
     – ClassNotFoundException? → API not supported
       // Virtual keyboard support
       try {
           // Check if class is available
           Class.forName("javamicroedition.sensor.SensorConnection");
           // SensorManager.findSensors("acceleration", null);
           useSensors = true;
       } catch (ClassNotFoundException e) {
           // Class not available: -> no Sensor API support.
           useSensors = false;
       } catch (Exception e) { }



11      © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
Example:
SENSORS: DYNAMIC DISCOVERY                                                                                               SensorBrowser



• Sensors can be discovered dynamically!
     private List sensorsList;
     private SensorInfo[] sensorInfos;

      public SensorBrowser() {
        display = Display.getDisplay(this);

          sensorsList = new List("Sensors list:", List.EXCLUSIVE);
          sensorInfos = SensorManager.findSensors(null, null);
          for (int i = 0; i < sensorInfos.length; i++) {
            sensorsList
                 .append(constructVisibleSensorName(sensorInfos[i]), null);
          }
          sensorsList.addCommand(CMD_LIST_DETAIL);
          sensorsList.addCommand(CMD_EXIT);
          sensorsList.setCommandListener(this);
      }


12    © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
Example:
SENSORS: CAN SAY WHO/WHAT THEY ARE                                                                                       SensorBrowser



• A wealth of inspectable information available
        SensorInfo sensorInfo = sensorInfos[currentSensorId];
        sensorDetail =
             new Form("Sensor detail: "
                  + constructVisibleSensorName(sensorInfo));
        sensorDetail.append(new StringItem("Quantity:", sensorInfo
             .getQuantity(), StringItem.LAYOUT_LEFT));
        sensorDetail.append(new StringItem("Context type:", sensorInfo
             .getContextType(), StringItem.LAYOUT_LEFT));
        sensorDetail.append(new StringItem("Connection type:",
             connectionTypeToString(sensorInfo.getConnectionType())));
        sensorDetail.append(new StringItem("URL:", sensorInfo.getUrl(),
             StringItem.LAYOUT_LEFT));
        String[] properties = sensorInfo.getPropertyNames();
        for (int i = 0; i < properties.length; i++) {
          Object value = sensorInfo.getProperty(properties[i]);
          sensorDetail.append(new StringItem(properties[i] + ":", value
               .toString(), StringItem.LAYOUT_LEFT));
        }

13    © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
Example: MovingBall
SENSORS: USING THEM – ROLL YOUR OWN
• Establish sensor connection
     // 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());
         }
     }


• Check data in game loop
     // 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




14            © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
SENSORS: USING THEM – COPY WITH PRIDE
• Use the wrapping classes from Nokia Developer examples
     private void enableSensors() {
         if (accelerationProvider != null) {
             accelerationProvider.close();
         }
         accelerationProvider = AccelerationProvider.getProvider(
             new AccelerationProvider.Listener() {
                 public void dataReceived(double ax, double ay, double az) {
                     if (isSensorTurning()) {
                         tilt = (int) ay;
                     }
                 }
             });
         if (accelerationProvider != null) {
             Main.sensorsSupported = true;
         } else {
             Main.sensorsSupported = false;
         }
     }

15          © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
SENSORS: IT‘S A CONDITION (INTERFACE)
• Operators                  temperature.addCondition(listener, new LimitCondition(50,Condition.GREATER_THAN));

    – OP_EQUALS
    – OP_GREATER_THAN
    – OP_GREATER_THAN_OR_EQUALS
    – OP_LESS_THAN
    – OP_LESS_THAN_OR_EQUALS
• Three Conditions and isMet()
    – LimitCondition – a value and an operator
    – RangeCondition – two operators, two values
    – ObjectCondition – compares to Objects (Strings, etc)

 16        © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
SENSORS: UI CONSIDERATIONS
• Calibrate! (see aMaze example)
• Look for change, not particular values
• Which axis is which (portrait vs landscape)
• Anticipate noise in readings (average values if needed)
• Don’t force accelerometer usage if it doesn’t add to the
 user experience

17    © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
SENSORS: PERFORMANCE
• Filter (LimitCondition) for values you’re really interested in
• Separate from mainloop – use Threads (see Cottage360
 video and source)
• Responsiveness is more critical than with keyboard input
• Choose right frequency (is 100 reads/sec really needed?)



18    © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
COMPATIBILITY




19   © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
COMPATIBILITY? CODE CONSIDERATIONS
• Source & binary compatible
    – xx years old Java ME apps run on
      full touch phones (and vice versa)!
• Downwards compatibility
     – Check API support of target phones
     – Lowest common denominator:
         → Nokia Java SDK 2.0 compiled app
         runs on old phones


20      © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
COMPATIBILITY? USE-CASE CONSIDERATIONS
• Input type
     – Sensors complementing buttons (universal)
         – Discrete input CAN be easier with buttons (f.ex Snake)!
     – Sensors complementing touch controls (touch&type)
         – Most common
     – Accelerometer only (no pre-DP2.0)
         – Rarer than you think, but possible! (f.ex wire loop game)


21      © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
DYNAMIC API USAGE
• Single code base for different phones
     – Code that uses new APIs
         – Externalize to extra class
     – Check API support at runtime
         – Instantiate class if supported
         – Different methods for checking available




22      © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
RESOURCES & TIPS




25   © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
NOKIA IDE FOR JAVA ME
     Integrated SDK + Toolchain                                                                                           JAD Editor




     App Templates                                                                                        Device SDK Manager


26     © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
CODE EXAMPLES
• Nokia IDE
      – Nokia Hub → Nokia Series 40
        Code Examples
• Online
      – bit.ly/JavaMeExamples
• Emulator
      – Help → MIDlet Samples
• Maps & LWUIT
      – C:NokiadevicesNokia_SDK_2_0_Javaplugins



 27       © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
CODE EXAMPLES SHOWN TODAY
• Wiki
• aMaze
• Racer
• Cottage360 (episode 19)




28       © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
GET STARTED
• Overview
     – www.developer.nokia.com/Develop/Java/Getting_started/
• Downloads
     – SDK: www.developer.nokia.com/Develop/Java/
     – LWUIT: projects.developer.nokia.com/LWUIT_for_Series_40
• Guides
     –   Design & User Experience
     –   Porting from Android
     –   www.developer.nokia.com/Develop/Java/Documentation/
     –   Training Videos: www.developer.nokia.com/Develop/Java/Learning/
     –   Code Examples: www.developer.nokia.com/Develop/Java/Code_examples/

30         © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
THANK YOU!                                                      QUESTIONS?
Want to learn more?
www.developer.nokia.com


Attila Csipa [@achipa]
Technology Wizard, Nokia



 31    © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa

Mais conteúdo relacionado

Semelhante a Advanced sensors in Series 40 Java ME apps

QuantumLeap, a Framework for Engineering Gestural User Interfaces based on th...
QuantumLeap, a Framework for Engineering Gestural User Interfaces based on th...QuantumLeap, a Framework for Engineering Gestural User Interfaces based on th...
QuantumLeap, a Framework for Engineering Gestural User Interfaces based on th...
Arthur Sluÿters
 
Android Sensors
Android SensorsAndroid Sensors
Android Sensors
Jussi Pohjolainen
 
Testing of Sensor Observation Services: A Performance Evaluation
Testing of Sensor Observation Services: A Performance EvaluationTesting of Sensor Observation Services: A Performance Evaluation
Testing of Sensor Observation Services: A Performance Evaluation
Ebrahim Poorazizi
 
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
Tsukasa Sugiura
 
Synapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindia android application development tutorial
Synapseindia android application development tutorial
Synapseindiappsdevelopment
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorial
Synapseindiappsdevelopment
 
Android Sensor System
Android Sensor SystemAndroid Sensor System
Android Sensor System
Yi-Hsiang Huang
 
SensorStudio introduction (IDC 2016)
SensorStudio introduction (IDC 2016)SensorStudio introduction (IDC 2016)
SensorStudio introduction (IDC 2016)
Herve Blanc
 
Don't Deploy Into the Dark: DORA Metrics for your K8s GitOps Deployments
Don't Deploy Into the Dark: DORA Metrics for your K8s GitOps DeploymentsDon't Deploy Into the Dark: DORA Metrics for your K8s GitOps Deployments
Don't Deploy Into the Dark: DORA Metrics for your K8s GitOps Deployments
Andreas Grabner
 
ME4AWSN - a Modeling Environment for Architecting WSNs
ME4AWSN - a Modeling Environment for Architecting WSNsME4AWSN - a Modeling Environment for Architecting WSNs
ME4AWSN - a Modeling Environment for Architecting WSNs
Ivano Malavolta
 
Operational Visibiliy and Analytics - BU Seminar
Operational Visibiliy and Analytics - BU SeminarOperational Visibiliy and Analytics - BU Seminar
Operational Visibiliy and Analytics - BU Seminar
Canturk Isci
 
PuppetConf 2016: Watching the Puppet Show – Sean Porter, Heavy Water Operations
PuppetConf 2016: Watching the Puppet Show – Sean Porter, Heavy Water OperationsPuppetConf 2016: Watching the Puppet Show – Sean Porter, Heavy Water Operations
PuppetConf 2016: Watching the Puppet Show – Sean Porter, Heavy Water Operations
Puppet
 
Observability and Orchestration of your GitOps Deployments with Keptn
Observability and Orchestration of your GitOps Deployments with KeptnObservability and Orchestration of your GitOps Deployments with Keptn
Observability and Orchestration of your GitOps Deployments with Keptn
Andreas Grabner
 
Sensor Cloud
Sensor CloudSensor Cloud
Sensor Cloud
Debjyoti Ghosh
 
OpenStack: Security Beyond Firewalls
OpenStack: Security Beyond FirewallsOpenStack: Security Beyond Firewalls
OpenStack: Security Beyond Firewalls
Giuseppe Paterno'
 
Openstack: security beyond firewalls
Openstack: security beyond firewallsOpenstack: security beyond firewalls
Openstack: security beyond firewalls
GARL
 
OpenTelemetry For GitOps: Tracing Deployments from Git Commit to Production
OpenTelemetry For GitOps: Tracing Deployments from Git Commit to ProductionOpenTelemetry For GitOps: Tracing Deployments from Git Commit to Production
OpenTelemetry For GitOps: Tracing Deployments from Git Commit to Production
Andreas Grabner
 
Labview.ppt
Labview.pptLabview.ppt
Labview.ppt
TITANIUMALFREDO
 
Windows7 Sensor & Location Platform
Windows7 Sensor & Location PlatformWindows7 Sensor & Location Platform
Windows7 Sensor & Location Platform
Dennis Loktionov
 
Internet of Things on AWS
Internet of Things on AWSInternet of Things on AWS
Internet of Things on AWS
Amazon Web Services
 

Semelhante a Advanced sensors in Series 40 Java ME apps (20)

QuantumLeap, a Framework for Engineering Gestural User Interfaces based on th...
QuantumLeap, a Framework for Engineering Gestural User Interfaces based on th...QuantumLeap, a Framework for Engineering Gestural User Interfaces based on th...
QuantumLeap, a Framework for Engineering Gestural User Interfaces based on th...
 
Android Sensors
Android SensorsAndroid Sensors
Android Sensors
 
Testing of Sensor Observation Services: A Performance Evaluation
Testing of Sensor Observation Services: A Performance EvaluationTesting of Sensor Observation Services: A Performance Evaluation
Testing of Sensor Observation Services: A Performance Evaluation
 
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
 
Synapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindia android application development tutorial
Synapseindia android application development tutorial
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorial
 
Android Sensor System
Android Sensor SystemAndroid Sensor System
Android Sensor System
 
SensorStudio introduction (IDC 2016)
SensorStudio introduction (IDC 2016)SensorStudio introduction (IDC 2016)
SensorStudio introduction (IDC 2016)
 
Don't Deploy Into the Dark: DORA Metrics for your K8s GitOps Deployments
Don't Deploy Into the Dark: DORA Metrics for your K8s GitOps DeploymentsDon't Deploy Into the Dark: DORA Metrics for your K8s GitOps Deployments
Don't Deploy Into the Dark: DORA Metrics for your K8s GitOps Deployments
 
ME4AWSN - a Modeling Environment for Architecting WSNs
ME4AWSN - a Modeling Environment for Architecting WSNsME4AWSN - a Modeling Environment for Architecting WSNs
ME4AWSN - a Modeling Environment for Architecting WSNs
 
Operational Visibiliy and Analytics - BU Seminar
Operational Visibiliy and Analytics - BU SeminarOperational Visibiliy and Analytics - BU Seminar
Operational Visibiliy and Analytics - BU Seminar
 
PuppetConf 2016: Watching the Puppet Show – Sean Porter, Heavy Water Operations
PuppetConf 2016: Watching the Puppet Show – Sean Porter, Heavy Water OperationsPuppetConf 2016: Watching the Puppet Show – Sean Porter, Heavy Water Operations
PuppetConf 2016: Watching the Puppet Show – Sean Porter, Heavy Water Operations
 
Observability and Orchestration of your GitOps Deployments with Keptn
Observability and Orchestration of your GitOps Deployments with KeptnObservability and Orchestration of your GitOps Deployments with Keptn
Observability and Orchestration of your GitOps Deployments with Keptn
 
Sensor Cloud
Sensor CloudSensor Cloud
Sensor Cloud
 
OpenStack: Security Beyond Firewalls
OpenStack: Security Beyond FirewallsOpenStack: Security Beyond Firewalls
OpenStack: Security Beyond Firewalls
 
Openstack: security beyond firewalls
Openstack: security beyond firewallsOpenstack: security beyond firewalls
Openstack: security beyond firewalls
 
OpenTelemetry For GitOps: Tracing Deployments from Git Commit to Production
OpenTelemetry For GitOps: Tracing Deployments from Git Commit to ProductionOpenTelemetry For GitOps: Tracing Deployments from Git Commit to Production
OpenTelemetry For GitOps: Tracing Deployments from Git Commit to Production
 
Labview.ppt
Labview.pptLabview.ppt
Labview.ppt
 
Windows7 Sensor & Location Platform
Windows7 Sensor & Location PlatformWindows7 Sensor & Location Platform
Windows7 Sensor & Location Platform
 
Internet of Things on AWS
Internet of Things on AWSInternet of Things on AWS
Internet of Things on AWS
 

Mais de Microsoft Mobile Developer

Healthcare apps for Nokia X and Nokia Asha
Healthcare apps for Nokia X and Nokia AshaHealthcare apps for Nokia X and Nokia Asha
Healthcare apps for Nokia X and Nokia Asha
Microsoft Mobile Developer
 
Push notifications on Nokia X
Push notifications on Nokia XPush notifications on Nokia X
Push notifications on Nokia X
Microsoft Mobile Developer
 
DIY Nokia Asha app usability studies
DIY Nokia Asha app usability studiesDIY Nokia Asha app usability studies
DIY Nokia Asha app usability studies
Microsoft Mobile Developer
 
Lessons learned from Nokia X UI reviews
Lessons learned from Nokia X UI reviewsLessons learned from Nokia X UI reviews
Lessons learned from Nokia X UI reviews
Microsoft Mobile Developer
 
Location based services for Nokia X and Nokia Asha using Geo2tag
Location based services for Nokia X and Nokia Asha using Geo2tagLocation based services for Nokia X and Nokia Asha using Geo2tag
Location based services for Nokia X and Nokia Asha using Geo2tag
Microsoft Mobile Developer
 
HERE Maps for the Nokia X platform
HERE Maps for the Nokia X platformHERE Maps for the Nokia X platform
HERE Maps for the Nokia X platform
Microsoft Mobile Developer
 
Nokia In-App Payment - UX considerations
Nokia In-App Payment - UX considerationsNokia In-App Payment - UX considerations
Nokia In-App Payment - UX considerations
Microsoft Mobile Developer
 
Introduction to Nokia Asha SDK 1.2 (beta)
Introduction to Nokia Asha SDK 1.2 (beta)Introduction to Nokia Asha SDK 1.2 (beta)
Introduction to Nokia Asha SDK 1.2 (beta)
Microsoft Mobile Developer
 
UX considerations when porting to Nokia X
UX considerations when porting to Nokia XUX considerations when porting to Nokia X
UX considerations when porting to Nokia X
Microsoft Mobile Developer
 
Kids' games and educational app design
Kids' games and educational app designKids' games and educational app design
Kids' games and educational app design
Microsoft Mobile Developer
 
Nokia X: opportunities for developers
Nokia X: opportunities for developersNokia X: opportunities for developers
Nokia X: opportunities for developers
Microsoft Mobile Developer
 
Lumia App Labs: Nokia Imaging SDK 1.1
Lumia App Labs: Nokia Imaging SDK 1.1Lumia App Labs: Nokia Imaging SDK 1.1
Lumia App Labs: Nokia Imaging SDK 1.1
Microsoft Mobile Developer
 
Intro to Nokia X software platform and tools
Intro to Nokia X software platform and toolsIntro to Nokia X software platform and tools
Intro to Nokia X software platform and tools
Microsoft Mobile Developer
 
Lumia App Labs: Lessons learned from 50 windows phone 8 design consultations
Lumia App Labs: Lessons learned from 50 windows phone 8 design consultationsLumia App Labs: Lessons learned from 50 windows phone 8 design consultations
Lumia App Labs: Lessons learned from 50 windows phone 8 design consultations
Microsoft Mobile Developer
 
Windows Phone 8 speech: parliamo con la nostra app
Windows Phone 8 speech: parliamo con la nostra appWindows Phone 8 speech: parliamo con la nostra app
Windows Phone 8 speech: parliamo con la nostra app
Microsoft Mobile Developer
 
La pubblicazione di un'applicazione sullo store
La pubblicazione di un'applicazione sullo storeLa pubblicazione di un'applicazione sullo store
La pubblicazione di un'applicazione sullo store
Microsoft Mobile Developer
 
Il pattern mvvm come strutturare al meglio il vostro progetto
Il pattern mvvm come strutturare al meglio il vostro progettoIl pattern mvvm come strutturare al meglio il vostro progetto
Il pattern mvvm come strutturare al meglio il vostro progetto
Microsoft Mobile Developer
 
Lens app trasformare il telefono in una fotocamera
Lens app trasformare il telefono in una fotocameraLens app trasformare il telefono in una fotocamera
Lens app trasformare il telefono in una fotocamera
Microsoft Mobile Developer
 
NFC, Bluetooth e comunicazione tra app
NFC, Bluetooth e comunicazione tra appNFC, Bluetooth e comunicazione tra app
NFC, Bluetooth e comunicazione tra app
Microsoft Mobile Developer
 
Nokia Asha webinar: Developing health-care applications for Nokia Asha phones
Nokia Asha webinar: Developing health-care applications for Nokia Asha phonesNokia Asha webinar: Developing health-care applications for Nokia Asha phones
Nokia Asha webinar: Developing health-care applications for Nokia Asha phones
Microsoft Mobile Developer
 

Mais de Microsoft Mobile Developer (20)

Healthcare apps for Nokia X and Nokia Asha
Healthcare apps for Nokia X and Nokia AshaHealthcare apps for Nokia X and Nokia Asha
Healthcare apps for Nokia X and Nokia Asha
 
Push notifications on Nokia X
Push notifications on Nokia XPush notifications on Nokia X
Push notifications on Nokia X
 
DIY Nokia Asha app usability studies
DIY Nokia Asha app usability studiesDIY Nokia Asha app usability studies
DIY Nokia Asha app usability studies
 
Lessons learned from Nokia X UI reviews
Lessons learned from Nokia X UI reviewsLessons learned from Nokia X UI reviews
Lessons learned from Nokia X UI reviews
 
Location based services for Nokia X and Nokia Asha using Geo2tag
Location based services for Nokia X and Nokia Asha using Geo2tagLocation based services for Nokia X and Nokia Asha using Geo2tag
Location based services for Nokia X and Nokia Asha using Geo2tag
 
HERE Maps for the Nokia X platform
HERE Maps for the Nokia X platformHERE Maps for the Nokia X platform
HERE Maps for the Nokia X platform
 
Nokia In-App Payment - UX considerations
Nokia In-App Payment - UX considerationsNokia In-App Payment - UX considerations
Nokia In-App Payment - UX considerations
 
Introduction to Nokia Asha SDK 1.2 (beta)
Introduction to Nokia Asha SDK 1.2 (beta)Introduction to Nokia Asha SDK 1.2 (beta)
Introduction to Nokia Asha SDK 1.2 (beta)
 
UX considerations when porting to Nokia X
UX considerations when porting to Nokia XUX considerations when porting to Nokia X
UX considerations when porting to Nokia X
 
Kids' games and educational app design
Kids' games and educational app designKids' games and educational app design
Kids' games and educational app design
 
Nokia X: opportunities for developers
Nokia X: opportunities for developersNokia X: opportunities for developers
Nokia X: opportunities for developers
 
Lumia App Labs: Nokia Imaging SDK 1.1
Lumia App Labs: Nokia Imaging SDK 1.1Lumia App Labs: Nokia Imaging SDK 1.1
Lumia App Labs: Nokia Imaging SDK 1.1
 
Intro to Nokia X software platform and tools
Intro to Nokia X software platform and toolsIntro to Nokia X software platform and tools
Intro to Nokia X software platform and tools
 
Lumia App Labs: Lessons learned from 50 windows phone 8 design consultations
Lumia App Labs: Lessons learned from 50 windows phone 8 design consultationsLumia App Labs: Lessons learned from 50 windows phone 8 design consultations
Lumia App Labs: Lessons learned from 50 windows phone 8 design consultations
 
Windows Phone 8 speech: parliamo con la nostra app
Windows Phone 8 speech: parliamo con la nostra appWindows Phone 8 speech: parliamo con la nostra app
Windows Phone 8 speech: parliamo con la nostra app
 
La pubblicazione di un'applicazione sullo store
La pubblicazione di un'applicazione sullo storeLa pubblicazione di un'applicazione sullo store
La pubblicazione di un'applicazione sullo store
 
Il pattern mvvm come strutturare al meglio il vostro progetto
Il pattern mvvm come strutturare al meglio il vostro progettoIl pattern mvvm come strutturare al meglio il vostro progetto
Il pattern mvvm come strutturare al meglio il vostro progetto
 
Lens app trasformare il telefono in una fotocamera
Lens app trasformare il telefono in una fotocameraLens app trasformare il telefono in una fotocamera
Lens app trasformare il telefono in una fotocamera
 
NFC, Bluetooth e comunicazione tra app
NFC, Bluetooth e comunicazione tra appNFC, Bluetooth e comunicazione tra app
NFC, Bluetooth e comunicazione tra app
 
Nokia Asha webinar: Developing health-care applications for Nokia Asha phones
Nokia Asha webinar: Developing health-care applications for Nokia Asha phonesNokia Asha webinar: Developing health-care applications for Nokia Asha phones
Nokia Asha webinar: Developing health-care applications for Nokia Asha phones
 

Último

HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
jpupo2018
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 

Último (20)

HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 

Advanced sensors in Series 40 Java ME apps

  • 1. ADVANCED EXAMPLES OF SENSOR USAGE IN JAVA ME ON SERIES 40 Attila Csipa [@achipa] Technology Wizard, Nokia 1 © 2012 Nokia Advanced examples of sensor usage in Java ME on Series 40 v1.2 February 19, 2013 Attila Csipa
  • 2. CONTENTS • Introduction – Platforms & Versions • Sensors – Physical vs virtual – JSR-256 – Measurables – Accelerometers – Usage – UI considerations – Performance – App Compatibility • Resources 2 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 3. PLATFORMS API Differences: bit.ly/S40Apis 5th Ed., FP1 6th Ed., Lite 6th Ed. 6th Ed., FP1 DP 1.0 DP 1.1 Developer Platform 2.0 http://www.developer.nokia.com/Devices/Device_specifications/Comparison.xhtml?dev=Asha_306,Nokia_Asha_309,Asha_311 3 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 4. DP 2.0 – NEW APIS Full touch Sensors & Multipoint UI Orientation Touch APIs Gestures: Virtual ... Pinch Keyboard 4 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 5. SENSORS Etymology Originated 1925–30 from sense + -or. Noun sensor (plural sensors) A device or organ that detects certain external stimuli and responds in a distinctive manner. 5 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 6. SENSORS: PHYSICAL VS VIRTUAL • Physical sensors (physical values, g or m/s, mbar, etc) – Acceleration – Light – ... • Virtual sensors (combined or interpreted values, %, enum-s) – Battery level – Orientation –… 6 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 7. SENSORS: JSR-256 JSR page at Nokia Developer JSR docs • JSR 256 Sensor API – Generic: designed also for temperature, blood pressure, etc. – Support on Series40 from DP2.0 (Asha Full Touch) – Also available on Symbian (from S60 5th edition onwards) • Two packages javax.microedition.sensor (read information) javax.microedition.sensor.control (settings, start/stop) 7 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 8. SENSORS: WHAT TO LOOK FOR • 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 8 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 9. SENSORS: ACCELEROMETERS ARE COOL • Enrich user interaction – Doesn’t suffer from finger size limits – Doesn’t suffer from screen size limits – Doesn’t interfere with what the user sees on the screen – Natural interaction (language/culture independent) • Ideal for games! 9 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 10. SENSORS: UNDERSTANDING ACCELEROMETERS • Acceleration is CHANGE of the speed vector • Standstill normalized value is 1.0, why? GRAVITY • Nitpick - accelerometers measure translation not rotation • Rotation can still be measured indirectly (we measure gravity vector hopping from one axis to the other) 10 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 11. Example: SENSORS: API AVAILABILITY Racer, aMaze • No System property for the API version? – Check Class availability – ClassNotFoundException? → API not supported // Virtual keyboard support try { // Check if class is available Class.forName("javamicroedition.sensor.SensorConnection"); // SensorManager.findSensors("acceleration", null); useSensors = true; } catch (ClassNotFoundException e) { // Class not available: -> no Sensor API support. useSensors = false; } catch (Exception e) { } 11 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 12. Example: SENSORS: DYNAMIC DISCOVERY SensorBrowser • Sensors can be discovered dynamically! private List sensorsList; private SensorInfo[] sensorInfos; public SensorBrowser() { display = Display.getDisplay(this); sensorsList = new List("Sensors list:", List.EXCLUSIVE); sensorInfos = SensorManager.findSensors(null, null); for (int i = 0; i < sensorInfos.length; i++) { sensorsList .append(constructVisibleSensorName(sensorInfos[i]), null); } sensorsList.addCommand(CMD_LIST_DETAIL); sensorsList.addCommand(CMD_EXIT); sensorsList.setCommandListener(this); } 12 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 13. Example: SENSORS: CAN SAY WHO/WHAT THEY ARE SensorBrowser • A wealth of inspectable information available SensorInfo sensorInfo = sensorInfos[currentSensorId]; sensorDetail = new Form("Sensor detail: " + constructVisibleSensorName(sensorInfo)); sensorDetail.append(new StringItem("Quantity:", sensorInfo .getQuantity(), StringItem.LAYOUT_LEFT)); sensorDetail.append(new StringItem("Context type:", sensorInfo .getContextType(), StringItem.LAYOUT_LEFT)); sensorDetail.append(new StringItem("Connection type:", connectionTypeToString(sensorInfo.getConnectionType()))); sensorDetail.append(new StringItem("URL:", sensorInfo.getUrl(), StringItem.LAYOUT_LEFT)); String[] properties = sensorInfo.getPropertyNames(); for (int i = 0; i < properties.length; i++) { Object value = sensorInfo.getProperty(properties[i]); sensorDetail.append(new StringItem(properties[i] + ":", value .toString(), StringItem.LAYOUT_LEFT)); } 13 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 14. Example: MovingBall SENSORS: USING THEM – ROLL YOUR OWN • Establish sensor connection // 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()); } } • Check data in game loop // 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 14 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 15. SENSORS: USING THEM – COPY WITH PRIDE • Use the wrapping classes from Nokia Developer examples private void enableSensors() { if (accelerationProvider != null) { accelerationProvider.close(); } accelerationProvider = AccelerationProvider.getProvider( new AccelerationProvider.Listener() { public void dataReceived(double ax, double ay, double az) { if (isSensorTurning()) { tilt = (int) ay; } } }); if (accelerationProvider != null) { Main.sensorsSupported = true; } else { Main.sensorsSupported = false; } } 15 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 16. SENSORS: IT‘S A CONDITION (INTERFACE) • Operators temperature.addCondition(listener, new LimitCondition(50,Condition.GREATER_THAN)); – OP_EQUALS – OP_GREATER_THAN – OP_GREATER_THAN_OR_EQUALS – OP_LESS_THAN – OP_LESS_THAN_OR_EQUALS • Three Conditions and isMet() – LimitCondition – a value and an operator – RangeCondition – two operators, two values – ObjectCondition – compares to Objects (Strings, etc) 16 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 17. SENSORS: UI CONSIDERATIONS • Calibrate! (see aMaze example) • Look for change, not particular values • Which axis is which (portrait vs landscape) • Anticipate noise in readings (average values if needed) • Don’t force accelerometer usage if it doesn’t add to the user experience 17 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 18. SENSORS: PERFORMANCE • Filter (LimitCondition) for values you’re really interested in • Separate from mainloop – use Threads (see Cottage360 video and source) • Responsiveness is more critical than with keyboard input • Choose right frequency (is 100 reads/sec really needed?) 18 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 19. COMPATIBILITY 19 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 20. COMPATIBILITY? CODE CONSIDERATIONS • Source & binary compatible – xx years old Java ME apps run on full touch phones (and vice versa)! • Downwards compatibility – Check API support of target phones – Lowest common denominator: → Nokia Java SDK 2.0 compiled app runs on old phones 20 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 21. COMPATIBILITY? USE-CASE CONSIDERATIONS • Input type – Sensors complementing buttons (universal) – Discrete input CAN be easier with buttons (f.ex Snake)! – Sensors complementing touch controls (touch&type) – Most common – Accelerometer only (no pre-DP2.0) – Rarer than you think, but possible! (f.ex wire loop game) 21 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 22. DYNAMIC API USAGE • Single code base for different phones – Code that uses new APIs – Externalize to extra class – Check API support at runtime – Instantiate class if supported – Different methods for checking available 22 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 23. RESOURCES & TIPS 25 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 24. NOKIA IDE FOR JAVA ME Integrated SDK + Toolchain JAD Editor App Templates Device SDK Manager 26 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 25. CODE EXAMPLES • Nokia IDE – Nokia Hub → Nokia Series 40 Code Examples • Online – bit.ly/JavaMeExamples • Emulator – Help → MIDlet Samples • Maps & LWUIT – C:NokiadevicesNokia_SDK_2_0_Javaplugins 27 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 26. CODE EXAMPLES SHOWN TODAY • Wiki • aMaze • Racer • Cottage360 (episode 19) 28 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 27. GET STARTED • Overview – www.developer.nokia.com/Develop/Java/Getting_started/ • Downloads – SDK: www.developer.nokia.com/Develop/Java/ – LWUIT: projects.developer.nokia.com/LWUIT_for_Series_40 • Guides – Design & User Experience – Porting from Android – www.developer.nokia.com/Develop/Java/Documentation/ – Training Videos: www.developer.nokia.com/Develop/Java/Learning/ – Code Examples: www.developer.nokia.com/Develop/Java/Code_examples/ 30 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa
  • 28. THANK YOU! QUESTIONS? Want to learn more? www.developer.nokia.com Attila Csipa [@achipa] Technology Wizard, Nokia 31 © 2012 Nokia Using accelerometers and other sensors from Java ME on Series 40 v1.1 October 23, 2012 Attila Csipa