SlideShare a Scribd company logo
Android	
  Sensors	
  
Jussi	
  Pohjolainen	
  
Overview	
  
•  SensorManager:	
  Access	
  to	
  sensors	
  if	
  
hardware	
  supports	
  
•  SensorEventListener:	
  Interface	
  for	
  class	
  to	
  
listen	
  sensor	
  values	
  as	
  they	
  change	
  in	
  =me	
  
SensorManager
•  Access	
  to	
  device’s	
  sensors	
  
•  Reference	
  by	
  calling	
  getSystemService
•  Disable	
  sensors	
  if	
  you	
  don’t	
  need	
  them!	
  (drain	
  
baEery)	
  
	
  
Sensor	
  Type	
  
•  Accelerometer,	
  Orienta=on	
  
•  Light	
  
•  Magne=c	
  field	
  
•  Proximity	
  
•  Temperature	
  
•  …	
  
	
  
Sampling	
  Rate	
  
•  How	
  fast	
  try	
  to	
  get	
  the	
  sensor	
  data	
  
•  Reques=ng	
  specific	
  sampling	
  rate..	
  Hint	
  to	
  the	
  
system,	
  no	
  guarantees	
  
•  SensorManager	
  holds	
  constant	
  variables:	
  
– Fastest	
  
– Game	
  
– Normal	
  
– User	
  Interface	
  
	
  
Accuracy	
  
•  How	
  accurate	
  is	
  the	
  informa=on?	
  
– High	
  
– Low	
  
– Medium	
  
– Unreliable	
  
•  This	
  is	
  informa=on	
  is	
  sent	
  to	
  listener	
  
SensorManager	
  Example	
  
public class SensorActivity extends Activity implements SensorEventListener {
private SensorManager mSensorManager;
private Sensor mAccelerometer;
public SensorActivity() {
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
}
protected void onResume() {
super.onResume();
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
}
protected void onPause() {
super.onPause();
mSensorManager.unregisteredListener(this);
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
public void onSensorChanged(SensorEvent event) {
}
}
Sensor	
  Simulator	
  
•  The	
  current	
  Android	
  emulator	
  does	
  not	
  
support	
  sensors	
  
•  Use	
  Sensor	
  Simulator,	
  open	
  source	
  project	
  
developed	
  by	
  Open	
  Intents	
  
•  Supports	
  accelerometer,	
  compass,	
  
orienta=on,	
  and	
  temperature	
  sensors,	
  
•  Download	
  it	
  from: 	
  	
  
– hEp://code.google.com/p/openintents/wiki/
SensorSimulator	
  
Instruc=ons	
  
1.  Download	
  the	
  latest	
  sensorsimulator-
x.x.x.zip from	
  the	
  download	
  tab	
  and	
  unzip.	
  
2.  Start	
  bin/sensorsimulator-x.x.x.jar (Java	
  
standalone	
  applica=on).	
  
1.  java –jar sensorsimulator-x.x.x.jar
3.  Install	
  bin/SensorSimulatorSettings-
x.x.x.apk on	
  your	
  Android	
  emulator.	
  
4.  Launch	
  SensorSimulator	
  on	
  the	
  emulator.	
  
5.  Enter	
  IP	
  address	
  and	
  socket	
  (port)	
  number	
  into	
  
the	
  emulator	
  
2.	
  Start	
  the	
  Sensor	
  Simulator	
  Jar	
  
3.	
  Install	
  Sensor	
  Simulator	
  Apk	
  
4.	
  Launch	
  Sensor	
  Simulator	
  in	
  
Emulator	
  
5.	
  Configure	
  App	
  
6.	
  Enable	
  Connec=on	
  
Android Sensors
Using	
  Sensor	
  Simulator	
  in	
  Your	
  App	
  
•  Add	
  external	
  JAR	
  lib/sensorsimulator-
lib.x.x.x.jar	
  to	
  your	
  project	
  
•  Use	
  sensorsimulator	
  classes	
  
•  Get	
  reference	
  to	
  SensorManagerSimulator	
  
instead	
  of	
  SensorManager	
  
•  Connect	
  to	
  simulator	
  
•  Add	
  permission	
  to	
  use	
  internet	
  
Add	
  .jar	
  to	
  Project	
  
Android Sensors
Android Sensors
Android Sensors

More Related Content

What's hot (20)

PPTX
Android Sensor and Framework - AWARE
DarrenJin
 
PDF
Generic sensors for the Web
Kenneth Rohde Christiansen
 
PPTX
Mobile Sensors
RAHUL KANEKAR
 
PPTX
Peno sensor
DarrenJin
 
PPT
Fire fighting robot using 8051 microcontroller
vibs1893
 
PPTX
Design of Arduino based fire fighting Robot
Nilanjan Mandal
 
PPTX
Human presence detection based room light controller using pir2.pptx [repaired]
nikhilsinghia
 
PPTX
Mebin progress
focusandiscover
 
PPTX
Sensors and its type by ss
sundas Shabbir
 
PPTX
Tk2323 lecture 10 sensor
MengChun Lam
 
PPTX
Fire Fighting Robot
Saadullah74
 
PPTX
fire fighting robot
ranjitha mudhiraj
 
PDF
IRJET- Fire Fighting Robot using Arduino
IRJET Journal
 
PPTX
Sensors by khaleel
khaleel basha
 
PDF
IRJET-Android Controlled Firefighting Robot using Arduino
IRJET Journal
 
PPTX
Automatic fire fighting robot
MaulikGoyani5
 
PPT
Fire Fighting Robot by saurabh
Saurabh Kumar
 
PPTX
Fire fighting robot
vijay kumar
 
PPTX
Fire fighting robot ppt
athmeg
 
PPTX
Automatic Fire Fighting Robot by St John College
NidhiRaut7
 
Android Sensor and Framework - AWARE
DarrenJin
 
Generic sensors for the Web
Kenneth Rohde Christiansen
 
Mobile Sensors
RAHUL KANEKAR
 
Peno sensor
DarrenJin
 
Fire fighting robot using 8051 microcontroller
vibs1893
 
Design of Arduino based fire fighting Robot
Nilanjan Mandal
 
Human presence detection based room light controller using pir2.pptx [repaired]
nikhilsinghia
 
Mebin progress
focusandiscover
 
Sensors and its type by ss
sundas Shabbir
 
Tk2323 lecture 10 sensor
MengChun Lam
 
Fire Fighting Robot
Saadullah74
 
fire fighting robot
ranjitha mudhiraj
 
IRJET- Fire Fighting Robot using Arduino
IRJET Journal
 
Sensors by khaleel
khaleel basha
 
IRJET-Android Controlled Firefighting Robot using Arduino
IRJET Journal
 
Automatic fire fighting robot
MaulikGoyani5
 
Fire Fighting Robot by saurabh
Saurabh Kumar
 
Fire fighting robot
vijay kumar
 
Fire fighting robot ppt
athmeg
 
Automatic Fire Fighting Robot by St John College
NidhiRaut7
 

Viewers also liked (20)

PPTX
Game controlling via android
محمد عدنان أبو ورد
 
PDF
Smart Phone CPU
오석 한
 
PDF
Android internals 00 - Introduction (rev_1.1)
Egor Elizarov
 
PDF
Android internals 08 - System start up, Media subsystem (rev_1.1)
Egor Elizarov
 
PPTX
Samsung processors: Exynos family
Sagar Patel
 
PDF
Android internals 01 - Basic concepts of mobile platforms (rev_1.1)
Egor Elizarov
 
PDF
Android internals 02 - High-level architecture, version control system (rev_1.1)
Egor Elizarov
 
PDF
Android internals 04 - “Androdized” kernel, Bionic, Logging subsystem (rev_1.1)
Egor Elizarov
 
PDF
Android internals 06 - Binder, Typical subsystem (rev_1.1)
Egor Elizarov
 
PDF
Android Security, Signing and Publishing
Jussi Pohjolainen
 
PDF
Android Http Connection and SAX Parsing
Jussi Pohjolainen
 
PPTX
Qt Translations
Jussi Pohjolainen
 
PDF
Responsive Web Site Design
Jussi Pohjolainen
 
PDF
C# for Java Developers
Jussi Pohjolainen
 
PDF
Quick Intro to Android Development
Jussi Pohjolainen
 
PDF
Building Web Services
Jussi Pohjolainen
 
PDF
Android Essential Tools
Jussi Pohjolainen
 
PDF
Android internals 03 - Build system, emulator (rev_1.1)
Egor Elizarov
 
PDF
Review Multicore processing based on ARM architecture
Mohammad Reza Khalifeh Mahmoodi
 
PDF
Android Wi-Fi Manager and Bluetooth Connection
Jussi Pohjolainen
 
Game controlling via android
محمد عدنان أبو ورد
 
Smart Phone CPU
오석 한
 
Android internals 00 - Introduction (rev_1.1)
Egor Elizarov
 
Android internals 08 - System start up, Media subsystem (rev_1.1)
Egor Elizarov
 
Samsung processors: Exynos family
Sagar Patel
 
Android internals 01 - Basic concepts of mobile platforms (rev_1.1)
Egor Elizarov
 
Android internals 02 - High-level architecture, version control system (rev_1.1)
Egor Elizarov
 
Android internals 04 - “Androdized” kernel, Bionic, Logging subsystem (rev_1.1)
Egor Elizarov
 
Android internals 06 - Binder, Typical subsystem (rev_1.1)
Egor Elizarov
 
Android Security, Signing and Publishing
Jussi Pohjolainen
 
Android Http Connection and SAX Parsing
Jussi Pohjolainen
 
Qt Translations
Jussi Pohjolainen
 
Responsive Web Site Design
Jussi Pohjolainen
 
C# for Java Developers
Jussi Pohjolainen
 
Quick Intro to Android Development
Jussi Pohjolainen
 
Building Web Services
Jussi Pohjolainen
 
Android Essential Tools
Jussi Pohjolainen
 
Android internals 03 - Build system, emulator (rev_1.1)
Egor Elizarov
 
Review Multicore processing based on ARM architecture
Mohammad Reza Khalifeh Mahmoodi
 
Android Wi-Fi Manager and Bluetooth Connection
Jussi Pohjolainen
 
Ad

Similar to Android Sensors (20)

PPTX
Sensors 9
Michael Shrove
 
PPTX
Android Lab Test : Using the sensor gyroscope (english)
Bruno Delb
 
PDF
Sensors in Android (old)
Ahsanul Karim
 
PPTX
Android 1.8 sensor
Ahsanul Karim
 
PDF
Week12.pdf
MuhammadMehran36
 
PDF
Sensor Garage Door.pdf
AZ Garage Doors Today
 
PPT
Sensing Mobile Devices talk from QCon London 2013
Adam Blum
 
PDF
Robotics unit3 sensors
Janarthanan B
 
PPTX
Making sense
Jared Sheehan
 
PPT
Synapseindia android application development tutorial
Synapseindiappsdevelopment
 
PPT
Synapseindia android apps development tutorial
Synapseindiappsdevelopment
 
PPTX
Android location and sensors API
eleksdev
 
PPTX
roboticsunit3sensors and -201013084413.pptx
DrPArivalaganASSTPRO
 
PPTX
Sensors & Actuators - Functional blocks of IOT
randomtp44
 
PDF
Android sensor
pyingkodi maran
 
PPTX
Sensing & Actuation.pptx
taruian
 
PDF
Advanced sensors in Series 40 Java ME apps
Microsoft Mobile Developer
 
PPTX
Using multitouch and sensors in Java
Intel Software Brasil
 
PDF
Mobile and Web Applications for Sensing Hazardous Room Temperature using Wire...
Mysa Vijay
 
PPTX
INTERNET OF THINGS IMPLEMENTATION FOR WIRELESS MONITORING OF AGRICULTURAL...
chaitanya ivvala
 
Sensors 9
Michael Shrove
 
Android Lab Test : Using the sensor gyroscope (english)
Bruno Delb
 
Sensors in Android (old)
Ahsanul Karim
 
Android 1.8 sensor
Ahsanul Karim
 
Week12.pdf
MuhammadMehran36
 
Sensor Garage Door.pdf
AZ Garage Doors Today
 
Sensing Mobile Devices talk from QCon London 2013
Adam Blum
 
Robotics unit3 sensors
Janarthanan B
 
Making sense
Jared Sheehan
 
Synapseindia android application development tutorial
Synapseindiappsdevelopment
 
Synapseindia android apps development tutorial
Synapseindiappsdevelopment
 
Android location and sensors API
eleksdev
 
roboticsunit3sensors and -201013084413.pptx
DrPArivalaganASSTPRO
 
Sensors & Actuators - Functional blocks of IOT
randomtp44
 
Android sensor
pyingkodi maran
 
Sensing & Actuation.pptx
taruian
 
Advanced sensors in Series 40 Java ME apps
Microsoft Mobile Developer
 
Using multitouch and sensors in Java
Intel Software Brasil
 
Mobile and Web Applications for Sensing Hazardous Room Temperature using Wire...
Mysa Vijay
 
INTERNET OF THINGS IMPLEMENTATION FOR WIRELESS MONITORING OF AGRICULTURAL...
chaitanya ivvala
 
Ad

More from Jussi Pohjolainen (20)

PDF
Moved to Speakerdeck
Jussi Pohjolainen
 
PDF
Java Web Services
Jussi Pohjolainen
 
PDF
Box2D and libGDX
Jussi Pohjolainen
 
PDF
libGDX: Screens, Fonts and Preferences
Jussi Pohjolainen
 
PDF
libGDX: Tiled Maps
Jussi Pohjolainen
 
PDF
libGDX: User Input and Frame by Frame Animation
Jussi Pohjolainen
 
PDF
Intro to Building Android Games using libGDX
Jussi Pohjolainen
 
PDF
Advanced JavaScript Development
Jussi Pohjolainen
 
PDF
Introduction to JavaScript
Jussi Pohjolainen
 
PDF
Introduction to AngularJS
Jussi Pohjolainen
 
PDF
libGDX: Scene2D
Jussi Pohjolainen
 
PDF
libGDX: Simple Frame Animation
Jussi Pohjolainen
 
PDF
libGDX: Simple Frame Animation
Jussi Pohjolainen
 
PDF
libGDX: User Input
Jussi Pohjolainen
 
PDF
Implementing a Simple Game using libGDX
Jussi Pohjolainen
 
PDF
Building Android games using LibGDX
Jussi Pohjolainen
 
PDF
Android Threading
Jussi Pohjolainen
 
PDF
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Jussi Pohjolainen
 
PDF
Creating Games for Asha - platform
Jussi Pohjolainen
 
PDF
Intro to Asha UI
Jussi Pohjolainen
 
Moved to Speakerdeck
Jussi Pohjolainen
 
Java Web Services
Jussi Pohjolainen
 
Box2D and libGDX
Jussi Pohjolainen
 
libGDX: Screens, Fonts and Preferences
Jussi Pohjolainen
 
libGDX: Tiled Maps
Jussi Pohjolainen
 
libGDX: User Input and Frame by Frame Animation
Jussi Pohjolainen
 
Intro to Building Android Games using libGDX
Jussi Pohjolainen
 
Advanced JavaScript Development
Jussi Pohjolainen
 
Introduction to JavaScript
Jussi Pohjolainen
 
Introduction to AngularJS
Jussi Pohjolainen
 
libGDX: Scene2D
Jussi Pohjolainen
 
libGDX: Simple Frame Animation
Jussi Pohjolainen
 
libGDX: Simple Frame Animation
Jussi Pohjolainen
 
libGDX: User Input
Jussi Pohjolainen
 
Implementing a Simple Game using libGDX
Jussi Pohjolainen
 
Building Android games using LibGDX
Jussi Pohjolainen
 
Android Threading
Jussi Pohjolainen
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Jussi Pohjolainen
 
Creating Games for Asha - platform
Jussi Pohjolainen
 
Intro to Asha UI
Jussi Pohjolainen
 

Recently uploaded (20)

PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 

Android Sensors

  • 1. Android  Sensors   Jussi  Pohjolainen  
  • 2. Overview   •  SensorManager:  Access  to  sensors  if   hardware  supports   •  SensorEventListener:  Interface  for  class  to   listen  sensor  values  as  they  change  in  =me  
  • 3. SensorManager •  Access  to  device’s  sensors   •  Reference  by  calling  getSystemService •  Disable  sensors  if  you  don’t  need  them!  (drain   baEery)    
  • 4. Sensor  Type   •  Accelerometer,  Orienta=on   •  Light   •  Magne=c  field   •  Proximity   •  Temperature   •  …    
  • 5. Sampling  Rate   •  How  fast  try  to  get  the  sensor  data   •  Reques=ng  specific  sampling  rate..  Hint  to  the   system,  no  guarantees   •  SensorManager  holds  constant  variables:   – Fastest   – Game   – Normal   – User  Interface    
  • 6. Accuracy   •  How  accurate  is  the  informa=on?   – High   – Low   – Medium   – Unreliable   •  This  is  informa=on  is  sent  to  listener  
  • 7. SensorManager  Example   public class SensorActivity extends Activity implements SensorEventListener { private SensorManager mSensorManager; private Sensor mAccelerometer; public SensorActivity() { mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) } protected void onResume() { super.onResume(); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL); } protected void onPause() { super.onPause(); mSensorManager.unregisteredListener(this); } public void onAccuracyChanged(Sensor sensor, int accuracy) { } public void onSensorChanged(SensorEvent event) { } }
  • 8. Sensor  Simulator   •  The  current  Android  emulator  does  not   support  sensors   •  Use  Sensor  Simulator,  open  source  project   developed  by  Open  Intents   •  Supports  accelerometer,  compass,   orienta=on,  and  temperature  sensors,   •  Download  it  from:     – hEp://code.google.com/p/openintents/wiki/ SensorSimulator  
  • 9. Instruc=ons   1.  Download  the  latest  sensorsimulator- x.x.x.zip from  the  download  tab  and  unzip.   2.  Start  bin/sensorsimulator-x.x.x.jar (Java   standalone  applica=on).   1.  java –jar sensorsimulator-x.x.x.jar 3.  Install  bin/SensorSimulatorSettings- x.x.x.apk on  your  Android  emulator.   4.  Launch  SensorSimulator  on  the  emulator.   5.  Enter  IP  address  and  socket  (port)  number  into   the  emulator  
  • 10. 2.  Start  the  Sensor  Simulator  Jar  
  • 11. 3.  Install  Sensor  Simulator  Apk  
  • 12. 4.  Launch  Sensor  Simulator  in   Emulator  
  • 16. Using  Sensor  Simulator  in  Your  App   •  Add  external  JAR  lib/sensorsimulator- lib.x.x.x.jar  to  your  project   •  Use  sensorsimulator  classes   •  Get  reference  to  SensorManagerSimulator   instead  of  SensorManager   •  Connect  to  simulator   •  Add  permission  to  use  internet  
  • 17. Add  .jar  to  Project