SlideShare une entreprise Scribd logo
1  sur  18
Android application development 
Sensor 
Programming
Android Sensors 
1. Android phones support different sensors. 
2. Today we write test code that reports which sensors our Android device supports. 
3. Unfortunately, the emulator supports none upto SDK 1.5. 
4. But we’ll see how many sensors are supported 
in real device 
5. We’ll create a project named SensorTest for this. 
We’ll test following sensor list: 
1. Accelerometer 
2. Light 
3. Magnetic Field 
4. Orientation 
5. Orientation Raw 
6. Proximity 
7. Temperature 
8. Tricorder This is for SDK 1.5
Let’s create a project named 
SensorTest
Activity to a ListActivity 
1. We change our Activity to a ListActivity
Android Sensors Test 
2. We’ll use SensorManager class 
3. So we declare a List for SensorInfo 
4. SensorInfo is a class defined by us which holds the sensor name and a boolean value 
whether its supported or not. 
5. So we create a SensorInfo class
ListActivity 
6. Let’s get back to our ListActivity 
7. We’ll now populate the list with all sensors and check whether they are enabled
Declare a List of SensorInfo 
8. We declare a List of SensorInfo 
9. Now we check each sensor one by one: 
First Accelerometer 
10. Now we check each sensor one by one: 
then Light
Android Sensors Test 
11. Now we check each sensor one by one: 
First Magnetic field 
12. Now we check each sensor one by one: 
then Orientation
Android Sensors Test 
13. Now we check each sensor one by one: 
First Orientation Raw 
14. Now we check each sensor one by one: 
then Proximity
Android Sensors Test 
15. Now we check each sensor one by one: 
First Temperature 
16. Now we check each sensor one by one: 
then Tricorder
Android Sensors Test 
17. To show the list we do the following by setting adapter 
Now we run the app in emulator. 
Except Accelerometer we see all sensors are disabled 
May be in later SDKs we’ll get more enabled sensors
Android Sensors Test 
Lets run this in Galaxy tab 
We see the following are enabled: 
1. Accelerometer 
2. Light 
3. Magnetic Field 
4. Orientation 
5. Orientation Raw 
6. Proximity 
So the sensor support varies from 
Vendor to vendor and model to model
Android Sensor Programming 
As we see that Accelerometer is the 
1. most commonly used sensor and also 
2. it has many applications in games development, 
We’ll see and example of Sensor programming with Accelerometer 
And as we don’t have option to move the emulator we may have to use a 
sensor simulator which will simulate the sensor data. 
So we download the library for sensorsimulation at: 
http://openintents.googlecode.com/files/sensorsimulator-1.1.0-rc1.zip 
http://code.google.com/p/openintents/downloads/detail?name=sensorsimulator-1.1.0-rc1.zip&can=2&q= 
http://code.google.com/p/openintents/wiki/SensorSimulator 
We can follow their instruction to use it. 
But here, we’ll do it in our real device, so simulator will not be required
Create a project as an example 
We create a layout with a simple image 
which will move according to the 
Accelerometer:
Our Activity
Android Sensor Programming 
Adding SensorEventListener inner class with data update
Android Sensor Programming 
Declaring variables and registering listener
Android Sensor Programming 
Register and unregister listener on activity onStop and onResume:

Contenu connexe

Tendances

Smartphone sensor and gesture
Smartphone sensor and gestureSmartphone sensor and gesture
Smartphone sensor and gestureBhavya5800
 
Design of Arduino based fire fighting Robot
Design of Arduino based fire fighting RobotDesign of Arduino based fire fighting Robot
Design of Arduino based fire fighting RobotNilanjan Mandal
 
Fire fighting robot using 8051 microcontroller
Fire fighting robot using 8051 microcontrollerFire fighting robot using 8051 microcontroller
Fire fighting robot using 8051 microcontrollervibs1893
 
Automatic Altitude Control of Quadroto3
Automatic Altitude Control of Quadroto3Automatic Altitude Control of Quadroto3
Automatic Altitude Control of Quadroto3isaac chang
 
Human presence detection based room light controller using pir2.pptx [repaired]
Human presence detection based room light controller using pir2.pptx [repaired]Human presence detection based room light controller using pir2.pptx [repaired]
Human presence detection based room light controller using pir2.pptx [repaired]nikhilsinghia
 
Automatic fire fighting robot
Automatic fire fighting robotAutomatic fire fighting robot
Automatic fire fighting robotMaulikGoyani5
 
Fire Fighting Robot
Fire Fighting RobotFire Fighting Robot
Fire Fighting RobotSaadullah74
 
Fire Fighting Robot by saurabh
Fire Fighting Robot by saurabhFire Fighting Robot by saurabh
Fire Fighting Robot by saurabhSaurabh Kumar
 
IRJET- Fire Fighting Robot using Arduino
IRJET- Fire Fighting Robot using ArduinoIRJET- Fire Fighting Robot using Arduino
IRJET- Fire Fighting Robot using ArduinoIRJET Journal
 
IRJET-Android Controlled Firefighting Robot using Arduino
IRJET-Android Controlled Firefighting Robot using ArduinoIRJET-Android Controlled Firefighting Robot using Arduino
IRJET-Android Controlled Firefighting Robot using ArduinoIRJET Journal
 
Fire fighting robot ppt
Fire fighting robot pptFire fighting robot ppt
Fire fighting robot pptathmeg
 
Fire fighting robot
Fire fighting robot Fire fighting robot
Fire fighting robot vijay kumar
 

Tendances (20)

Smartphone sensor and gesture
Smartphone sensor and gestureSmartphone sensor and gesture
Smartphone sensor and gesture
 
Peno sensor
Peno sensorPeno sensor
Peno sensor
 
Design of Arduino based fire fighting Robot
Design of Arduino based fire fighting RobotDesign of Arduino based fire fighting Robot
Design of Arduino based fire fighting Robot
 
Fire fighting robot using 8051 microcontroller
Fire fighting robot using 8051 microcontrollerFire fighting robot using 8051 microcontroller
Fire fighting robot using 8051 microcontroller
 
Generic sensors for the Web
Generic sensors for the WebGeneric sensors for the Web
Generic sensors for the Web
 
Automatic Altitude Control of Quadroto3
Automatic Altitude Control of Quadroto3Automatic Altitude Control of Quadroto3
Automatic Altitude Control of Quadroto3
 
fire fighting robot
fire fighting robotfire fighting robot
fire fighting robot
 
Human presence detection based room light controller using pir2.pptx [repaired]
Human presence detection based room light controller using pir2.pptx [repaired]Human presence detection based room light controller using pir2.pptx [repaired]
Human presence detection based room light controller using pir2.pptx [repaired]
 
Automatic fire fighting robot
Automatic fire fighting robotAutomatic fire fighting robot
Automatic fire fighting robot
 
Fire Fighting Robot
Fire Fighting RobotFire Fighting Robot
Fire Fighting Robot
 
Mebin progress
Mebin progressMebin progress
Mebin progress
 
Fire Fighting Robot by saurabh
Fire Fighting Robot by saurabhFire Fighting Robot by saurabh
Fire Fighting Robot by saurabh
 
Human Detection Robot
Human Detection RobotHuman Detection Robot
Human Detection Robot
 
IRJET- Fire Fighting Robot using Arduino
IRJET- Fire Fighting Robot using ArduinoIRJET- Fire Fighting Robot using Arduino
IRJET- Fire Fighting Robot using Arduino
 
IRJET-Android Controlled Firefighting Robot using Arduino
IRJET-Android Controlled Firefighting Robot using ArduinoIRJET-Android Controlled Firefighting Robot using Arduino
IRJET-Android Controlled Firefighting Robot using Arduino
 
Fire fighting robot ppt
Fire fighting robot pptFire fighting robot ppt
Fire fighting robot ppt
 
Different types of sensors
Different types of sensorsDifferent types of sensors
Different types of sensors
 
Fire fighting robot
Fire fighting robot Fire fighting robot
Fire fighting robot
 
Syn ankit
Syn ankitSyn ankit
Syn ankit
 
Fire sensing robo
Fire sensing roboFire sensing robo
Fire sensing robo
 

En vedette

Android - Sensor Manager
Android - Sensor ManagerAndroid - Sensor Manager
Android - Sensor ManagerYong Heui Cho
 
Sensors and their applications
Sensors and their applicationsSensors and their applications
Sensors and their applicationsnitigga92
 
Top sensors inside the smartphone you want to know
Top sensors inside the smartphone you want to knowTop sensors inside the smartphone you want to know
Top sensors inside the smartphone you want to knowsoniyasag
 
Smart Systems and The Future of Smart Products_ Group 4_FinalPaper (1)
Smart Systems and The Future of Smart Products_ Group 4_FinalPaper (1)Smart Systems and The Future of Smart Products_ Group 4_FinalPaper (1)
Smart Systems and The Future of Smart Products_ Group 4_FinalPaper (1)Michael Hanacek
 
Finding sensor related energy black holes in smartphone applications
Finding sensor related energy black holes in smartphone applicationsFinding sensor related energy black holes in smartphone applications
Finding sensor related energy black holes in smartphone applicationsSchool of Engineering, HKUST
 
Environmental Sensor Network Paper
Environmental Sensor Network PaperEnvironmental Sensor Network Paper
Environmental Sensor Network PaperZoey Y. Kang
 
Review Paper on Smart Sensor Network for Air Quality Monitoring
Review Paper on Smart Sensor Network for Air Quality MonitoringReview Paper on Smart Sensor Network for Air Quality Monitoring
Review Paper on Smart Sensor Network for Air Quality MonitoringAM Publications
 
Get Moving with Core Motion
Get Moving with Core MotionGet Moving with Core Motion
Get Moving with Core Motionjblocksom
 
Location based services
Location based servicesLocation based services
Location based serviceswatsonda
 
Post-PC: Geolocation & Maps in the Android Ecosystem
Post-PC: Geolocation & Maps in the Android EcosystemPost-PC: Geolocation & Maps in the Android Ecosystem
Post-PC: Geolocation & Maps in the Android EcosystemMichael Genkin
 
Head First XML Layout on Android
Head First XML Layout on AndroidHead First XML Layout on Android
Head First XML Layout on AndroidYuki Anzai
 
Draft activity recognition from accelerometer data
Draft activity recognition from accelerometer dataDraft activity recognition from accelerometer data
Draft activity recognition from accelerometer dataRaghu Palakodety
 
Husky Lines Mobile App: Adapting transportation studies to our changing techn...
Husky Lines Mobile App: Adapting transportation studies to our changing techn...Husky Lines Mobile App: Adapting transportation studies to our changing techn...
Husky Lines Mobile App: Adapting transportation studies to our changing techn...nacis_slides
 

En vedette (18)

Android - Sensor Manager
Android - Sensor ManagerAndroid - Sensor Manager
Android - Sensor Manager
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Introduction to sensors
Introduction to sensorsIntroduction to sensors
Introduction to sensors
 
Sensors and their applications
Sensors and their applicationsSensors and their applications
Sensors and their applications
 
Top sensors inside the smartphone you want to know
Top sensors inside the smartphone you want to knowTop sensors inside the smartphone you want to know
Top sensors inside the smartphone you want to know
 
Sensors
SensorsSensors
Sensors
 
Smart Systems and The Future of Smart Products_ Group 4_FinalPaper (1)
Smart Systems and The Future of Smart Products_ Group 4_FinalPaper (1)Smart Systems and The Future of Smart Products_ Group 4_FinalPaper (1)
Smart Systems and The Future of Smart Products_ Group 4_FinalPaper (1)
 
Finding sensor related energy black holes in smartphone applications
Finding sensor related energy black holes in smartphone applicationsFinding sensor related energy black holes in smartphone applications
Finding sensor related energy black holes in smartphone applications
 
Environmental Sensor Network Paper
Environmental Sensor Network PaperEnvironmental Sensor Network Paper
Environmental Sensor Network Paper
 
Review Paper on Smart Sensor Network for Air Quality Monitoring
Review Paper on Smart Sensor Network for Air Quality MonitoringReview Paper on Smart Sensor Network for Air Quality Monitoring
Review Paper on Smart Sensor Network for Air Quality Monitoring
 
Get Moving with Core Motion
Get Moving with Core MotionGet Moving with Core Motion
Get Moving with Core Motion
 
Location based services
Location based servicesLocation based services
Location based services
 
Post-PC: Geolocation & Maps in the Android Ecosystem
Post-PC: Geolocation & Maps in the Android EcosystemPost-PC: Geolocation & Maps in the Android Ecosystem
Post-PC: Geolocation & Maps in the Android Ecosystem
 
GPS
GPSGPS
GPS
 
Sensors 9
Sensors   9Sensors   9
Sensors 9
 
Head First XML Layout on Android
Head First XML Layout on AndroidHead First XML Layout on Android
Head First XML Layout on Android
 
Draft activity recognition from accelerometer data
Draft activity recognition from accelerometer dataDraft activity recognition from accelerometer data
Draft activity recognition from accelerometer data
 
Husky Lines Mobile App: Adapting transportation studies to our changing techn...
Husky Lines Mobile App: Adapting transportation studies to our changing techn...Husky Lines Mobile App: Adapting transportation studies to our changing techn...
Husky Lines Mobile App: Adapting transportation studies to our changing techn...
 

Similaire à Android Sensor

Sensors in Android (old)
Sensors in Android (old)Sensors in Android (old)
Sensors in Android (old)Ahsanul Karim
 
Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai
Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai
Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai Itvedant
 
Synapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindiappsdevelopment
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorialSynapseindiappsdevelopment
 
SMART BUNK BED CHILD MONITORING SYSTEM.pdf
SMART BUNK BED CHILD MONITORING SYSTEM.pdfSMART BUNK BED CHILD MONITORING SYSTEM.pdf
SMART BUNK BED CHILD MONITORING SYSTEM.pdfUmesh chandra
 
Android 8 behavior changes
Android 8 behavior changesAndroid 8 behavior changes
Android 8 behavior changesInnovationM
 
Diving into VS 2015 Day2
Diving into VS 2015 Day2Diving into VS 2015 Day2
Diving into VS 2015 Day2Akhil Mittal
 
React Native: Is It Worth It? UA Mobile 2017.
React Native: Is It Worth It? UA Mobile 2017.React Native: Is It Worth It? UA Mobile 2017.
React Native: Is It Worth It? UA Mobile 2017.UA Mobile
 
Android location and sensors API
Android location and sensors APIAndroid location and sensors API
Android location and sensors APIeleksdev
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answerskavinilavuG
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorialmaster760
 

Similaire à Android Sensor (20)

Android 1.8 sensor
Android 1.8 sensorAndroid 1.8 sensor
Android 1.8 sensor
 
Sensors in Android (old)
Sensors in Android (old)Sensors in Android (old)
Sensors in Android (old)
 
Week12.pdf
Week12.pdfWeek12.pdf
Week12.pdf
 
Android tutorial1
Android tutorial1Android tutorial1
Android tutorial1
 
Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai
Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai
Everything About Android - Itvedant, Thane | Mumbai | Navi Mumbai
 
Control-Project
Control-ProjectControl-Project
Control-Project
 
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
 
cpuk10745
cpuk10745cpuk10745
cpuk10745
 
Android sensor
Android sensorAndroid sensor
Android sensor
 
SMART BUNK BED CHILD MONITORING SYSTEM.pdf
SMART BUNK BED CHILD MONITORING SYSTEM.pdfSMART BUNK BED CHILD MONITORING SYSTEM.pdf
SMART BUNK BED CHILD MONITORING SYSTEM.pdf
 
Ppt 2 android_basics
Ppt 2 android_basicsPpt 2 android_basics
Ppt 2 android_basics
 
Android 8 behavior changes
Android 8 behavior changesAndroid 8 behavior changes
Android 8 behavior changes
 
Aptech Apps
Aptech Apps Aptech Apps
Aptech Apps
 
Diving into VS 2015 Day2
Diving into VS 2015 Day2Diving into VS 2015 Day2
Diving into VS 2015 Day2
 
React Native: Is It Worth It? UA Mobile 2017.
React Native: Is It Worth It? UA Mobile 2017.React Native: Is It Worth It? UA Mobile 2017.
React Native: Is It Worth It? UA Mobile 2017.
 
Android location and sensors API
Android location and sensors APIAndroid location and sensors API
Android location and sensors API
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answers
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Game controlling via android
Game controlling via androidGame controlling via android
Game controlling via android
 

Plus de nationalmobileapps (17)

Fragment
Fragment Fragment
Fragment
 
Android Location Api
Android Location ApiAndroid Location Api
Android Location Api
 
Play Store
Play StorePlay Store
Play Store
 
GCM (push notification)
GCM (push notification)GCM (push notification)
GCM (push notification)
 
Ad Mob
Ad MobAd Mob
Ad Mob
 
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
 
Google Map V2
Google Map V2Google Map V2
Google Map V2
 
Database
DatabaseDatabase
Database
 
Activity & Shared Preference
Activity & Shared PreferenceActivity & Shared Preference
Activity & Shared Preference
 
Intent
IntentIntent
Intent
 
Support Multiple Screen
Support Multiple ScreenSupport Multiple Screen
Support Multiple Screen
 
Listview
ListviewListview
Listview
 
Android UI
Android UIAndroid UI
Android UI
 
Event Handling
Event HandlingEvent Handling
Event Handling
 
Project anatomy & hello world
Project anatomy & hello worldProject anatomy & hello world
Project anatomy & hello world
 
Mobile Application capacity building activities
Mobile Application capacity building activities Mobile Application capacity building activities
Mobile Application capacity building activities
 
Future of Smart phone in Bangladesh
Future of Smart phone in Bangladesh Future of Smart phone in Bangladesh
Future of Smart phone in Bangladesh
 

Dernier

Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsPooky Knightsmith
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleCeline George
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 

Dernier (20)

Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young minds
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP Module
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 

Android Sensor

  • 1. Android application development Sensor Programming
  • 2. Android Sensors 1. Android phones support different sensors. 2. Today we write test code that reports which sensors our Android device supports. 3. Unfortunately, the emulator supports none upto SDK 1.5. 4. But we’ll see how many sensors are supported in real device 5. We’ll create a project named SensorTest for this. We’ll test following sensor list: 1. Accelerometer 2. Light 3. Magnetic Field 4. Orientation 5. Orientation Raw 6. Proximity 7. Temperature 8. Tricorder This is for SDK 1.5
  • 3. Let’s create a project named SensorTest
  • 4. Activity to a ListActivity 1. We change our Activity to a ListActivity
  • 5. Android Sensors Test 2. We’ll use SensorManager class 3. So we declare a List for SensorInfo 4. SensorInfo is a class defined by us which holds the sensor name and a boolean value whether its supported or not. 5. So we create a SensorInfo class
  • 6. ListActivity 6. Let’s get back to our ListActivity 7. We’ll now populate the list with all sensors and check whether they are enabled
  • 7. Declare a List of SensorInfo 8. We declare a List of SensorInfo 9. Now we check each sensor one by one: First Accelerometer 10. Now we check each sensor one by one: then Light
  • 8. Android Sensors Test 11. Now we check each sensor one by one: First Magnetic field 12. Now we check each sensor one by one: then Orientation
  • 9. Android Sensors Test 13. Now we check each sensor one by one: First Orientation Raw 14. Now we check each sensor one by one: then Proximity
  • 10. Android Sensors Test 15. Now we check each sensor one by one: First Temperature 16. Now we check each sensor one by one: then Tricorder
  • 11. Android Sensors Test 17. To show the list we do the following by setting adapter Now we run the app in emulator. Except Accelerometer we see all sensors are disabled May be in later SDKs we’ll get more enabled sensors
  • 12. Android Sensors Test Lets run this in Galaxy tab We see the following are enabled: 1. Accelerometer 2. Light 3. Magnetic Field 4. Orientation 5. Orientation Raw 6. Proximity So the sensor support varies from Vendor to vendor and model to model
  • 13. Android Sensor Programming As we see that Accelerometer is the 1. most commonly used sensor and also 2. it has many applications in games development, We’ll see and example of Sensor programming with Accelerometer And as we don’t have option to move the emulator we may have to use a sensor simulator which will simulate the sensor data. So we download the library for sensorsimulation at: http://openintents.googlecode.com/files/sensorsimulator-1.1.0-rc1.zip http://code.google.com/p/openintents/downloads/detail?name=sensorsimulator-1.1.0-rc1.zip&can=2&q= http://code.google.com/p/openintents/wiki/SensorSimulator We can follow their instruction to use it. But here, we’ll do it in our real device, so simulator will not be required
  • 14. Create a project as an example We create a layout with a simple image which will move according to the Accelerometer:
  • 16. Android Sensor Programming Adding SensorEventListener inner class with data update
  • 17. Android Sensor Programming Declaring variables and registering listener
  • 18. Android Sensor Programming Register and unregister listener on activity onStop and onResume: