Android Application Development Tutorial. Topics Lecture 4 Overview Overview of Sensors Programming Tutorial 1: Tracking location with GPS and Google.

Slides:



Advertisements
Similar presentations
Google Android Introduction to Mobile Computing. Android is part of the build a better phone process Open Handset Alliance produces Android Comprises.
Advertisements

Android Application Development Tutorial. Topics Lecture 6 Overview Programming Tutorial 3: Sending/Receiving SMS Messages.
Google APIs & Location Based Applications -Krishna Achanta
Bruce Scharlau, University of Aberdeen, 2010 Android and Location Mobile Computing Unless otherwise stated, images are from android sdk.
Ando-it-yourself droid Praveen Kumar Pendyala. Outline Brief intro to the Droid developement Setting up the Life saviors - Development tools Hello Droid.
ANDROID DEVELOPMENT KELLY MCBEAN. DEVELOPMENT ENVIRONMENT OVERVIEW Eclipse Standard IDE for Developing Android Applications Install: 1.Java (JDK) – Since.
Introducing to Location in Android LOCATION IS EVERYTHING Kamil Lelonek Kamil Lelonek
Cosc 5/4730 Android Maps v2. Maps V1 and V2 In March 2013 google removed the ability to get a map key for version 1. Version 2 had been introduced in.
Location based services
GPS and MapView. First In the emulator, set the time zone to something (e.g., east coast) and check that the time is correct. Otherwise, the gps emulator.
Programming Mobile Applications with Android
Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna.
CS378 - Mobile Computing Maps. Using Google Maps Like other web services requires an API key from Google ons/google-apis/mapkey.html.
Chapter 11: Discover! Incorporating Google Maps
Android and Project Structure. Android Android OS – Built on Linux Kernel – Phones – Netbooks – Readers – Other???
Location and Maps Content Getting Location Getting Google Map In application Test on Emulator/Device.
2. Setting Up Your Android Development Environment.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
Setting up the Development Environment Copyright © SUPINFO. All rights reserved Preparation.
Android Tutorial Larry Walters OOSE Fall References This tutorial is a brief overview of some major concepts…Android is much richer and more complex.
INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming.
Android Programming. Outline Preparation Create new project Build and Run a project Debug a project Deploy on devices.
Android Application Development 2013 PClassic Chris Murphy 1.
CS378 - Mobile Computing Maps. Using Google Maps Content on using Google Maps inside your app Alternatives: Open Street Maps –
Map Applications.
Android Sensors & Async Callbacks Jules White Bradley Dept. of Electrical and Computer Engineering Virginia Tech
Route Tracker App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Mobile Programming Lecture 1 Getting Started. Today's Agenda About the Eclipse IDE Hello, World! Project Android Project Structure Intro to Activities,
Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez.
Google Maps Android API v2 吳俊興 國立高雄大學 資訊工程學系 CSF645 – Mobile Computing 行動計算
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
Subtitle touch | Title of presentation | Date DD/MM/YYYY Touch Cloud Android SDK Ghady Rayess – Jan 19 th, 2013.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
Android Programming By Mohsen Biglari Android Programming, Part1: Introduction 1 Part1: Introduction By Mohsen Biglari.
Chapter 1: Voilà! Meet the Android
Sensing. Possible sensors on devices – Documented in SensorEvent class Accelerometer (m/s 2 ) – acceleration in x, y, z axes Magnetic Field (micro Tesla)
Chapter 2: Simplify! The Android User Interface
PARSING FACEBOOK DATA FOR ANDROID 1. Step by Step  Import Android SDK  Get the hash key  Create a new app  Create a new project in Eclipse 
Copyright© Jeffrey Jongko, Ateneo de Manila University Android.
Introduction to Android. Android as a system, is a java based operating system that runs on the Linux kernel. The system is very lightweight and full.
Presentation Seminar on “IMAGE SLIDER –AN ANDROID APPLICATION”
DUE Hello World on the Android Platform.
Android Accessing GPS Ken Nguyen Clayton State University 2012.
1 CMSC 628: Introduction to Mobile Computing Nilanjan Banerjee Introduction to Mobile Computing University of Maryland Baltimore County
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Presented By: Muhammad Tariq Software Engineer Android Training course.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
Android Boot Camp for Developers Using Java, 3E
Android architecture & setting up. Android operating system comprises of different software components arranges in stack. Different components of android.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Location. GPS Global Positioning System – At least 4 satellites typically used 3 required extra for error detection and altitude typically accurate within.
Sensors in android. App being more applicable Keeping track of your heart beat while jogging. Pointing the phone camera towards the night sky to know.
ANDROID APPLICATION DEVELOPMENT. ANDROID DEVELOPMENT DEVELOPER.ANDROID.COM/INDEX.HTML THE OFFICIAL SITE FOR ANDROID DEVELOPERS. PROVIDES THE ANDROID SDK.
TCS Internal Maps. 2 TCS Internal Objective Objective :  MAPS o Integration of Maps.
Intoduction to Andriod studio Environment With a hello world program.
Cosc 5/4735 YouTube API. YouTube The YouTube Android Player API enables you to incorporate video playback functionality into your Android applications.
Accelerometer based motion gestures for mobile devices Presented by – Neel Parikh Advisor Committee members Dr. Chris Pollett Dr. Robert Chun Dr. Mark.
CS371m - Mobile Computing Maps. Using Google Maps Content on using Google Maps inside your app Alternatives Exist: – Open Street Maps –
Android apps development - Eclipse, Android SDK, and ADT plugin Introduction of.
3 rd -party APIs Kalin Kadiev Astea Solutions AD.
Vijay Kumar Kolagani Dr. Yingcai Xiao
Chapter 2: Simplify! The Android User Interface
Android Application Maps 1.
Android Studio, Android System Basics and Git
Sensors, maps and fragments:
Vijay Kumar Kolagani Dr. Yingcai Xiao
Presentation transcript:

Android Application Development Tutorial

Topics Lecture 4 Overview Overview of Sensors Programming Tutorial 1: Tracking location with GPS and Google Maps

Overview of Sensors The Android Sensor Platform and how to use it

Open Source Platform Developers are able to access goodies Hardware capabilities made available

Hardware-oriented Features FeatureDescription Camera A class that enables your application to interact with the camera to snap a photo, acquire images for a preview screen, and modify parameters used to govern how the camera operates. SensorClass representing a sensor. Use getSensorList(int) to get the list of available Sensors. SensorManagerA class that permits access to the sensors available within the Android platform. SensorEventListener An interface used for receiving notifications from the SensorManager when sensor values have changed. An application implements this interface to monitor one or more sensors available in the hardware. SensorEvent This class represents a sensor event and holds information such as the sensor type (e.g., accelerometer, orientation, etc.), the time-stamp, accuracy and of course the sensor's data. MediaRecorder A class, used to record media samples, that can be useful for recording audio activity within a specific location (such as a baby nursery). Audio clippings can also be analyzed for identification purposes in an access-control or security application. For example, it could be helpful to open the door to your time-share with your voice, rather than having to meet with the realtor to get a key. GeomagneticField This class is used to estimated estimate magnetic field at a given point on Earth, and in particular, to compute the magnetic declination from true north. FaceDetector A class that permits basic recognition of a person's face as contained in a bitmap. Using this as a device lock means no more passwords to remember biometrics capability on a cell phone.

Sensor and SensorManager Sensor type (Sensor class) Orientation, accelerometer, light, magnetic field, proximity, temperature, etc. Sampling rate Fastest, game, normal, user interface. When an application requests a specific sampling rate, it is really only a hint, or suggestion, to the sensor subsystem. There is no guarantee of a particular rate being available. Accuracy High, low, medium, unreliable.

Programming Tutorial Simulating an Android application that accesses positioning sensors

Preparing for the Tutorial Must have Eclipse IDE installed Must have Android SDK installed Must have knowledge of Java Must have the external Google Maps library installed in your SDK environment. The Maps library is included with the Google APIs add-on, which you can install using the Android SDK and AVD Manager.

Get a Google Maps API Key A Google Maps API key is required to integrate Google Maps into your Android application. To apply for a key: 1.Locate the SDK debug certificate in the default folder of "C:\Documents and Settings\ \Local Settings\Application Data\Android". The filename of the debug keystore is debug.keystore. 2.Copy the debug.keystore file to a folder named C:\Android\. 3.Open the command window and navigate to C:\Program Files\Java\ \bin to locate the Keytool.exe. 4.Execute the following to extract the MD5 fingerprint: keytool.exe -list -alias androiddebugkey -keystore "C:\Android\debug.keystore" -storepass android -keypass android 5.Copy the MD5 certificate fingerprint and navigate your web browser to: 6.Follow the instructions on the page to complete the application and obtain the Google Maps key. For more information on using Google Maps in Android application development:

Create an Android Virtual Device (AVD) Defines the system image and device settings used by the Emulator To create an AVD in Eclipse: 1.Select Window > Android SDK and AVD Manager. The Android SDK and AVD Manager displays. 2.Make sure the entry for Virtual Devices is selected and click New. The Create new AVD window displays. 3.Enter a Name for the AVD. 4.Select Google APIs (API level 3) as the Target. 5.Click Create AVD. 6.Close the Android SDK and AVD Manager.

Create the Android Project To create the project in Eclipse: 1.Select File > New > Project. 2.Select Android Project in the Android folder and click Next. 3.Enter GPSSimulator as the Project Name. 4.Select Google APIs (Platform 1.5) as the Build Target. 5.Enter GPSSimulator as the Application name. 6.Enter com.android.gpssimulator as the Package name. 7.Enter GPSSimulator as the Activity name. 8.Click Finish.

The New Android Project

Modify the AndroidManifest.xml File Add permissions for GPS To modify the AndroidManifest.xml file: 1.Click on the res folder in the GPSSimulator project. 2.Double-click AndroidManifest.xml to display the GPSSimulator Manifest. 3.Enter the following lines before the application tag. 4.Save the changes to the file.

Add LocationManager to get Updates public class GPSSimulator extends Activity { private LocationManager lm; private LocationListener locationListener; // Called when the activity is first public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // use the LocationManager class to obtain GPS locations lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationListener = new MyLocationListener(); lm.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, locationListener); }

Add MyLocationListener private class MyLocationListener implements LocationListener public void onLocationChanged(Location loc) { if (loc != null) { Toast.makeText(getBaseContext(), "Location changed : Lat: " + loc.getLatitude() + " Lng: " + loc.getLongitude(), Toast.LENGTH_SHORT).show(); public void onProviderDisabled(String provider) { // TODO Auto-generated method stub public void onProviderEnabled(String provider) { // TODO Auto-generated method stub public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub }

Test the GPSSimulator To test in Eclipse: 1.Switch to DDMS view. 2.Find the Location Controls in the Emulator Control tab. 3.Click the GPX tab and click Load GPX. 4.Locate and select the GPX file. 5.Click Play to begin sending coordinates to the Emulator.

Add ability to use Google Maps Update the Manifest with two lines. <manifest xmlns:android=" package="com.android.GPSSimulator"> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <application

Add MapView to main.xml <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <com.google.android.maps.MapView android:layout_width="fill_parent" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apiKey=Your API Key Here" />

Modify GPSSimulator to use Google Maps public class GPSSimulator extends MapActivity { private LocationManager lm; private LocationListener locationListener; private MapView mapView; private MapController mc; // Called when the activity is first public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // use the LocationManager class to obtain GPS locations lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationListener = new MyLocationListener(); lm.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, locationListener); mapView = (MapView) findViewById(R.id.mapview1); mc = mapView.getController(); protected boolean isRouteDisplayed() { return false; } private class MyLocationListener implements LocationListener public void onLocationChanged(Location loc) { if (loc != null) { Toast.makeText(getBaseContext(), "Location changed : Lat: " + loc.getLatitude() + " Lng: " + loc.getLongitude(), Toast.LENGTH_SHORT).show(); GeoPoint p = new GeoPoint( (int) (loc.getLatitude() * 1E6), (int) (loc.getLongitude() * 1E6)); mc.animateTo(p); mc.setZoom(16); mapView.invalidate(); public void onProviderDisabled(String provider) { public void onProviderEnabled(String provider) { public void onStatusChanged(String provider, int status, Bundle extras) { }

View the Location on the Map

Internet Layers The Internet, is based on a layered architecture called the TCP/IP stack. Link Layer Protocols: ARP and RARP Internet Layer Protocols: IP, ping, etc. Transport Protocols: TCP and UDP Application Layer Protocols: HTTP, FTP, DNS, etc.

Client-Server Communication A server machine is identified on the Internet by some IP address Daemons are the processes running in the background which are listening all the time for connection requests from clients on a particular port number. Once a connection request comes into the server on a given port, the corresponding daemon can choose to accept it, and if so, a connection is established. Then the application layer protocol is typically used for the client to get or send data to the server.

End of Tutorial 1