Android Sensor Programming. Weihong Yu



Similar documents
Sensors & Motion Sensors in Android platform. Minh H Dang CS286 Spring 2013

Android Sensors. CPRE 388 Fall 2015 Iowa State University

Android Sensors. XI Jornadas SLCENT de Actualización Informática y Electrónica

Using the Android Sensor API

Using Sensors on the Android Platform. Andreas Terzis Android N00b

ELET4133: Embedded Systems. Topic 15 Sensors

Android Framework. How to use and extend it

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL II)

Objective. Android Sensors. Sensor Manager Sensor Types Examples. Page 2

! Sensors in Android devices. ! Motion sensors. ! Accelerometer. ! Gyroscope. ! Supports various sensor related tasks

Android app development course

App Development for Smart Devices. Lec #5: Android Sensors

Developing Sensor Applications on Intel Atom Processor-Based Android* Phones and Tablets

Programming Mobile Applications with Android

Using Extensions or Cordova Plugins in your RhoMobile Application Darryn

06 Team Project: Android Development Crash Course; Project Introduction

Obsoleted chapter from The Busy Coder's Guide to Advanced Android Development

E0-245: ASP. Lecture 16+17: Physical Sensors. Dipanjan Gope

Arduino & Android. A How to on interfacing these two devices. Bryant Tram

Android Programming Lecture 18: Menus Sensors 11/11/2011

CS 403X Mobile and Ubiquitous Computing Lecture 6: Maps, Sensors, Widget Catalog and Presentations Emmanuel Agu

Lab 1 (Reading Sensors & The Android API) Week 3

Android Concepts and Programming TUTORIAL 1

Graduate presentation for CSCI By Janakiram Vantipalli ( Janakiram.vantipalli@colorado.edu )

Internal Services. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr. Rajiv Ramnath

SENSORS ON ANDROID PHONES. Indian Institute of Technology Kanpur Commonwealth of Learning Vancouver

Android. Mobile Computing Design and Implementation. Application Components, Sensors. Peter Börjesson

How to Convert 3-Axis Directions and Swap X-Y Axis of Accelerometer Data within Android Driver by: Gang Chen Field Applications Engineer

Designing An Android Sensor Subsystem Pitfalls and Considerations

HP TouchPad Sensor Setup for Android

Sensors and Cellphones

Module 1: Sensor Data Acquisition and Processing in Android

Sensor Fusion Mobile Platform Challenges and Future Directions Jim Steele VP of Engineering, Sensor Platforms, Inc.

Motion Sensing with mcube igyro Delivering New Experiences for Motion Gaming and Augmented Reality for Android Mobile Devices

Introduction to NaviGenie SDK Client API for Android

WEARIT DEVELOPER DOCUMENTATION 0.2 preliminary release July 20 th, 2013

CSE476 Mobile Application Development. Yard. Doç. Dr. Tacha Serif Department of Computer Engineering Yeditepe University

Pedometer Project 1 Mr. Michaud /

An Introduction to Android Application Development. Serdar Akın, Haluk Tüfekçi

Frameworks & Android. Programmeertechnieken, Tim Cocx

AN APPLYING OF ACCELEROMETER IN ANDROID PLATFORM FOR CONTROLLING WEIGHT

AUTOMATIC HUMAN FREE FALL DETECTION USING ANDROID

Android Development Tutorial. Nikhil Yadav CSE40816/ Pervasive Health Fall 2011

How to develop your own app

UNMANNED AERIAL VEHICLE (UAV) SAFETY SYSTEM USING ANDROID APP

ECE 455/555 Embedded System Design. Android Programming. Wei Gao. Fall

Application Note IMU Visualization Software

Detecting User Activities using the Accelerometer on Android Smartphones

Quick Start Guide ActiGraph GT9X Link + ActiLife

Robot Sensors. Outline. The Robot Structure. Robots and Sensors. Henrik I Christensen

ANDROID. Programming basics

Developing Android Apps for BlackBerry 10. JAM854 Mike Zhou- Developer Evangelist, APAC Nov 30, 2012

Effective Use of Android Sensors Based on Visualization of Sensor Information

Kathy Au Billy Yi Fan Zhou Department of Electrical and Computer Engineering University of Toronto { kathy.au, billy.zhou }@utoronto.

Google Android: An Emerging Innovative Software Platform For Mobile Devices

Tegra Android Accelerometer Whitepaper

An Introduction to Android

An inertial haptic interface for robotic applications

Android Basics. Xin Yang

Presenting Android Development in the CS Curriculum

類 比 與 MEMS 感 測 器 啟 動 智 慧 新 生 活 The Smart-World Started with ST (Analog, MEMS and Sensors)

Performance issues in writing Android Apps

Develop a Hello World project in Android Studio Capture, process, store, and display an image. Other sensors on Android phones

A DECISION TREE BASED PEDOMETER AND ITS IMPLEMENTATION ON THE ANDROID PLATFORM

Use It Free: Instantly Knowing Your Phone Attitude

Digital Field Mapping

AN4503 Application note

Acellus Natural 3D Tablet

Android and OpenGL. Android Smartphone Programming. Matthias Keil. University of Freiburg

A MOTION ACTIVITY MONITOR MONITOR POHYBOVÉ AKTIVITY

App Development for Smart Devices. Lec #2: Android Tools, Building Applications, and Activities

Making Android Motion Applications Using the Unity 3D Engine

Des Moines Area Community College

Information regarding the Lockheed F-104 Starfighter F-104 LN-3. An article published in the Zipper Magazine #48. December Theo N.M.M.

Improving Workflow Efficiency using the Trimble R10 with SurePoint. Marco Wuethrich Trimble Applications Specialist

Android For Java Developers. Marko Gargenta Marakana

ELDERLY SUPPORT - ANDROID APPLICATION FOR FALL DETECTION AND TRACKING TEJITHA RUDRARAJU. B.E, Anna University, India, 2011 A REPORT

Lecture 1 Introduction to Android

Vibrations can have an adverse effect on the accuracy of the end effector of a

Transcription:

Android Sensor Programming Weihong Yu

Sensors Overview The Android platform is ideal for creating innovative applications through the use of sensors. These built-in sensors measure motion, orientation, and various environmental conditions. These sensors are capable of providing raw data with high precision and accuracy, and are useful if you want to monitor three-dimensional device movement or positioning, or you want to monitor changes in the ambient environment near a device.

Android Sensors Overview Android Sensors: MIC Camera Temperature Location (GPS or Network) Orientation Accelerometer Proximity Pressure Light

hardware-based sensors Sensors physical components built into a handset or tablet device They derive their data by directly measuring specific environmental properties, such as acceleration, geomagnetic field strength, or angular change software-based sensors not physical devices, although they mimic hardware-based sensors Software-based sensors derive their data from one or more of the hardware-based sensors and are sometimes called virtual sensors or synthetic sensors Examples: the linear acceleration sensor

categories of sensors supported by Android platform Motion sensors :measure acceleration forces and rotational forces along three axes accelerometers, gravity sensors, gyroscopes, etc. Environmental sensors: measure various environmental parameters, such as ambient air temperature and pressure, illumination, and humidity barometers, photometers, and thermometers. Position sensors: measure the physical position of a device orientation sensors and magnetometers.

Sensor Coordinate System When a device is held in its default orientation the X axis is horizontal and points to the right the Y axis is vertical and points up and the Z axis points toward the outside of the screen face

Android sensor framework The sensor framework provides several classes and interfaces that help you perform a wide variety of sensor-related tasks Determine which sensors are available on a device. Determine an individual sensor's capabilities, such as its maximum range, manufacturer, power requirements, and resolution. Acquire raw sensor data and define the minimum rate at which you acquire sensor data. Register and unregister sensor event listeners that monitor sensor changes.

Sensor Framework-sensor Manager You can use this class to create an instance of the sensor service This class provides various methods for accessing and listing sensors, registering and unregistering sensor event listeners, and acquiring orientation information. This class also provides several sensor constants that are used to report sensor accuracy, set data acquisition rates, and calibrate sensors.

Sensor Framework---Sensor You can use this class to create an instance of a specific sensor. This class provides various methods that let you determine a sensor's capabilities.

Sensor Framework---SensorEvent The system uses this class to create a sensor event object, which provides information about a sensor event. A sensor event object includes the following information: the raw sensor data the type of sensor that generated the event the accuracy of the data the timestamp for the event

Sensor Framework---SensorEventListener You can use this interface to create two callback methods that receive notifications (sensor events) when sensor values change or when sensor accuracy changes. onaccuracychanged(sensor sensor, int accuracy) :Called when the accuracy of a sensor has changed. onsensorchanged(sensorevent event) :Called when sensor values have changed.

Basic Steps for Programming Step 1--access a SensorManager via getsystemservice(sensor_service). Android supports several sensors via the SensorManager Step 2--access the Sensor via the sensormanager.getdefaultsensor() method Step 3--Once you acquired a sensor, you can register a SensorEventListener object on it. This listener will get informed, if the sensor data changes. Step 4--To avoid the unnecessary usage of battery you register your listener in the onresume() method and de-register it in the onpause() method.

Android Activity lifecycle

Example 1:List all sensors Step 1--- get a reference to the sensor service private SensorManager msensormanager; msensormanager = (SensorManager) getsystemservice(context.sensor_servi CE); Step2---get a list of all sensors on a device List<Sensor> devicesensors = msensormanager.getsensorlist(sensor.typ E_ALL);

Example 2:Use Accelerometer Step 1---get an instance of SensorManager and Sensor msensormanager = (SensorManager) getsystemservice(context.sensor_servic E); maccelerometer = msensormanager.getdefaultsensor(sensor.t YPE_ACCELEROMETER);

Example 2:Use Accelerometer Step 2---register a sensor event listener msensormanager.registerlistener(this, maccelerometer, SensorManager.SENSOR_DELAY_GAME));

Example 2:Use Accelerometer Step 3---override onsensorchanged(sensorevent event) and use event.values[] to get the co-ordinates @Override public void onsensorchanged(sensorevent event) { float x = event.values[0]; float y = event.values[1]; float z = event.values[2]; }

Codes for Using Accelerometer Get the Sensor Service and Sensor public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_acc_main); mytx=(textview)this.findviewbyid(r.id.tx); myty=(textview)this.findviewbyid(r.id.ty); mytz=(textview)this.findviewbyid(r.id.tz); sm=(sensormanager)this.getsystemservice(context.se NSOR_SERVICE); mysensor=sm.getdefaultsensor(sensor.type_accele ROMETER); }

Codes for Using Accelerometer Define an instance of SensorEventListener private final SensorEventListener mysensorlistenr=new SensorEventListener(){ public void onaccuracychanged(sensor sensor, int accuracy) { // TODO Auto-generated method stub } public void onsensorchanged(sensorevent event) { // TODO Auto-generated method stub mytx.settext(string.valueof(event.values[0])); myty.settext(string.valueof(event.values[1])); mytz.settext(string.valueof(event.values[2])); } };

Codes for Using Accelerometer Register the object of SensorEventListener protected void onresume() { // TODO Auto-generated method stub super.onresume(); sm.registerlistener(mysensorlistenr, mysensor, SensorManager.SENSOR_DELAY_NORMAL); }

Codes for Using Accelerometer De-Register the object of SensorEventListener protected void onpause() { // TODO Auto-generated method stub super.onpause(); sm.unregisterlistener(mysensorlistenr); }

Running result on the Emulator But you currently can't test all sensor code on the emulator because the emulator cannot emulate all sensors. Most of the time,you must test your sensor code on a physical device.