SlideShare a Scribd company logo
Android Development Tutorial
Nikhil Yadav
CSE40816/60816 - Pervasive Health
Fall 2011
Outline

Setting up the Android Development
Environment (Windows)

Starters Android “Hello World” empty project

Android project components

Example: Tabbed application project

Accessing Sensors on an Android Device:
GPS, accelerometers and the Google API

Database connections – Local SQLite and
remote access
Android Development Environment

Download the latest JDK (Java distribution)

Download the Eclipse IDE (e.g. Galileo) from:
www.eclipse.org/downloads/

Install the Android SDK starter package from:
http://developer.android.com/sdk/index.html

In Eclipse, install the ADT (Android Developer
Tools) plugin:
http://developer.android.com/sdk/eclipse-adt.html

Instructions on setting up the SDK and
development Environment can be found on:
http://developer.android.com/sdk/installing.html
The Android SDK starter package

Not the full development environment, includes
the core SDK tools

Keep track of where you have downloaded this
it is required for the ADT plugin setup, e.g.
C:Program Filesandroid-sdk-windowsplatform-
tools>

Useful for “adb” commands
The ADT plugin

Gives access to Android development tools
from within the Eclipse IDE

Automates the process of building a new
Android project by setting up all the basic files
needed for development

Allows code signing of your app so it can be
distributed
Installing the ADT plugin
(Link: http://developer.android.com/sdk/eclipse-adt.html#installing)
To simplify ADT setup, it is recommend installing the Android SDK prior to installing ADT
.Eclipse 3.5 (Galileo) and 3.6 (Helios)
1.Start Eclipse, then select Help>Install New Software....
2.Click Add, in the top-right corner.
3.In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and
the following URL for the Location:
https://dl-ssl.google.com/android/eclipse/
Note: If you have troubles try using "http" instead of "https”Click OK.
4.In the Available Software dialog, select the checkbox next to Developer Tools
and click Next.
5.In the next window, you'll see a list of the tools to be downloaded. Click Next.
6.Read and accept the license agreements, then click Finish.
7.When the installation completes, restart Eclipse.
Configuring the ADT plugin
1.Select Window>Preferences...to open the Preferences panel (Mac OS
X:Eclipse>Preferences).
2.Select Android from the left panel.
3.For the SDK Location in the main panel, click Browse...and locate your
downloaded SDK directory (e.g. C:Program Filesandroid-sdk-windows)
4.Click Apply, then OK
Android SDK and AVD manager

Add your virtual development devices using this

AVD is a target device simulator: no sensors
Android tutorial
Android SDK and AVD Manager

Used for updating Android SDK tools etc.
Pointers
Update the system’s PATH variable to recognize two folders inside your
android-sdk-winwows. The first is: tools and the second is platform-
tools.
1.Windows > Start > Control Panel > System > Advanced > Environment
Variables > System Variables > PATH > Edit
2.Add references to the sub-folders mentioned above. In this example:
c:android-sdk-windowstools;C:android-sdk-windowsplatform-tools;
3.OK
Make sure Java and Eclipse Environments and path variables are setup
correctly:
Some interesting tutorials on Android projects can be found on:
http://www.hometutorials.com/google-android.html
Starters: “Hello World”
Android tutorial
Android tutorial
Once you complete the New Project Wizard, ADT creates the following
folders and files in your new project:
•src/ Includes your stub Activity Java file. All other Java files for your
application go here.
•<Android Version>/ (e.g., Android 1.5/) Includes the android.jar file
that your application will build against.
•gen/ This contains the Java files generated by ADT, such as your
R.java file and interfaces created from AIDL files.
•assets/This is empty. You can use it to store raw asset files.
•res/A folder for your application resources, such as drawable files,
layout files, string values, etc.
•AndroidManifest.xml The Android Manifest for your project.
•default.propertiesThis file contains project settings, such as the build
target.
Android Project Components
Android tutorial
Android tutorial
Android tutorial
Android tutorial
Android tutorial
Android tutorial
Android tutorial
A Tabbed application
Android tutorial
mainmenu.java
main.xml
Android Manifest.xml
tabs.java
Accessing Sensors
There are various sensors on the Android
phones, e.g. GPS, camera, accelerometer
 Cannot be tested on Simulator
 Tutorial and sample source code to use GPS
and accelerometer sensors available soon
● Using the Wi-Fi and Bluetooth Interfaces
instructions on:
http://www.tutorialforandroid.com/2009/10/turn-off-turn-on-wifi-in-android-using.html
http://developer.android.com/guide/topics/wireless/bluetooth.html
GPS Sensor Access
● To use GPS functionality in your Android application, you'll
need to add the ACCESS_FINE_LOCATION permission to
the AndroidManifest.xml file.
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />
●In Android, location-based services are provided by the
LocationManager class located in the android.location
package.
● Using the LocationManager class, your application can
obtain periodic updates of the device's geographical locations
as well as fire an intent when it enters the proximity of a
certain location.
Accelerometer and Access to other
Sensors
● An instance of the SensorManager is required in order to
retrieve informations about the supported sensors.
● No permission is required to access the sensor service. It is
then possible to retrieve the list of available sensors of a
certain type.
● For an accelerometer sensor, the type to use is given by the
Sensor.TYPE_ACCELEROMETER constant.
● If at least one Sensor exists, it is possible to register a
SensorEventListener for a Sensor of the list.
● It is possible to specify the delivering rate for sensor
events. Specified rate must be one of :
SensorManager.SENSOR_DELAY_FASTEST : as fast as
possible
SensorManager.SENSOR_DELAY_GAME : rate suitable for
game
SensorManager.SENSOR_DELAY_NORMAL : normal rate
SensorManager.SENSOR_DELAY_UI : rate suitable for UI
Thread
Android and Databases
● Access to remote database e.g. MySQL can
occur using a PHP script hosted on the server
performing the query and JSON formatting for
data exchange for reference check out the
example at:
http://www.helloandroid.com/tutorials/connecting-
mysql-database
● Local light weight database system.
http://developer.android.com/reference/android/d
atabase/sqlite/SQLiteDatabase.html
Questions?
http://developer.android.com/index.html

More Related Content

PPT
Getting started with android dev and test perspective
PDF
Steps to install android
PPTX
Eclipse & android setup
PPTX
Android chapter02-setup1-sdk
PPT
9780134433646 annuzzi ch02 (1)
PPT
Android Applications Development
PPT
Google Android
PPTX
Android development session 5 - Debug android studio
Getting started with android dev and test perspective
Steps to install android
Eclipse & android setup
Android chapter02-setup1-sdk
9780134433646 annuzzi ch02 (1)
Android Applications Development
Google Android
Android development session 5 - Debug android studio

What's hot (18)

PPTX
Android development beginners faq
PPT
android-tutorial-for-beginner
PDF
Day1 before getting_started
PPTX
Introduction to android coding
PPT
Industrial Training in Android Application
PDF
Android chapter02-setup2-emulator
PDF
Android Development: Build Android App from Scratch
PDF
Android Development
PDF
Android 6.0 Marshmallow - Everything you need to know !
PDF
Getting Started with Android Development
PDF
Android tutorial
PDF
AndroidManifest
PPTX
Week 1 - Android Study Jams
PPTX
Android Development Training
PDF
Android Development Workshop
PPTX
Android, Gradle & Dependecies
PPTX
Android Studio Overview
PPTX
Android installation guide
Android development beginners faq
android-tutorial-for-beginner
Day1 before getting_started
Introduction to android coding
Industrial Training in Android Application
Android chapter02-setup2-emulator
Android Development: Build Android App from Scratch
Android Development
Android 6.0 Marshmallow - Everything you need to know !
Getting Started with Android Development
Android tutorial
AndroidManifest
Week 1 - Android Study Jams
Android Development Training
Android Development Workshop
Android, Gradle & Dependecies
Android Studio Overview
Android installation guide
Ad

Viewers also liked (15)

PDF
Confi - What is Gender
PDF
Joan Paylor Resume 7-2014
PPTX
Prezentacja suchecka
PDF
23 pastoralepistles
DOCX
PDF
Curriculum Vitae v10
PPTX
Jornada: es posible internacionalizar el mercado de alimentos? | speakers
PDF
Emag SOE, Tezpur University Edition II
PDF
Joan Paylor Resume 7-2014
PDF
Emag SOE, Tezpur University Edition I
PDF
Confi - What is Gender Intro
DOCX
Relacioni
PPTX
Powerpoint msdm
PPTX
Renzo Piano
PDF
Presentacion de la Academia de Inbound Marketing 2016 - BIB 360 / DOTZERO
Confi - What is Gender
Joan Paylor Resume 7-2014
Prezentacja suchecka
23 pastoralepistles
Curriculum Vitae v10
Jornada: es posible internacionalizar el mercado de alimentos? | speakers
Emag SOE, Tezpur University Edition II
Joan Paylor Resume 7-2014
Emag SOE, Tezpur University Edition I
Confi - What is Gender Intro
Relacioni
Powerpoint msdm
Renzo Piano
Presentacion de la Academia de Inbound Marketing 2016 - BIB 360 / DOTZERO
Ad

Similar to Android tutorial (20)

PDF
Android tutorial ppt
PDF
Android tutorial
PPT
Android tutorial for beginners-traininginbangalore.com
PPT
Easy steps to develop android application (tutorial)
PPT
Mobile app development snovasys
PPT
Android Training in Chandigarh | Industrial Training in Android Apps Development
PPT
Android app developers in bangalore- thorsignia
PPT
Android
PPTX
01 introduction & setup - Android
PPT
Android-Tutorial.ppt
PPT
Android tutorial
PPT
Android tutorial
PPT
Android tutorial
PPT
Android tutorial
PPT
Android tutorial
PPTX
Developing for Android-Types of Android Application
PPTX
PDF
An Introduction To Android
PPT
Webinar on Google Android SDK
PPTX
Android Workshop: Day 1 Part 3
Android tutorial ppt
Android tutorial
Android tutorial for beginners-traininginbangalore.com
Easy steps to develop android application (tutorial)
Mobile app development snovasys
Android Training in Chandigarh | Industrial Training in Android Apps Development
Android app developers in bangalore- thorsignia
Android
01 introduction & setup - Android
Android-Tutorial.ppt
Android tutorial
Android tutorial
Android tutorial
Android tutorial
Android tutorial
Developing for Android-Types of Android Application
An Introduction To Android
Webinar on Google Android SDK
Android Workshop: Day 1 Part 3

Recently uploaded (20)

PDF
01-Introduction-to-Information-Management.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Lesson notes of climatology university.
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Cell Structure & Organelles in detailed.
PPTX
Institutional Correction lecture only . . .
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Pharma ospi slides which help in ospi learning
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
01-Introduction-to-Information-Management.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
102 student loan defaulters named and shamed – Is someone you know on the list?
Lesson notes of climatology university.
2.FourierTransform-ShortQuestionswithAnswers.pdf
TR - Agricultural Crops Production NC III.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Cell Structure & Organelles in detailed.
Institutional Correction lecture only . . .
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
O7-L3 Supply Chain Operations - ICLT Program
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Pharma ospi slides which help in ospi learning
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
FourierSeries-QuestionsWithAnswers(Part-A).pdf
human mycosis Human fungal infections are called human mycosis..pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...

Android tutorial

  • 1. Android Development Tutorial Nikhil Yadav CSE40816/60816 - Pervasive Health Fall 2011
  • 2. Outline  Setting up the Android Development Environment (Windows)  Starters Android “Hello World” empty project  Android project components  Example: Tabbed application project  Accessing Sensors on an Android Device: GPS, accelerometers and the Google API  Database connections – Local SQLite and remote access
  • 3. Android Development Environment  Download the latest JDK (Java distribution)  Download the Eclipse IDE (e.g. Galileo) from: www.eclipse.org/downloads/  Install the Android SDK starter package from: http://developer.android.com/sdk/index.html  In Eclipse, install the ADT (Android Developer Tools) plugin: http://developer.android.com/sdk/eclipse-adt.html  Instructions on setting up the SDK and development Environment can be found on: http://developer.android.com/sdk/installing.html
  • 4. The Android SDK starter package  Not the full development environment, includes the core SDK tools  Keep track of where you have downloaded this it is required for the ADT plugin setup, e.g. C:Program Filesandroid-sdk-windowsplatform- tools>  Useful for “adb” commands
  • 5. The ADT plugin  Gives access to Android development tools from within the Eclipse IDE  Automates the process of building a new Android project by setting up all the basic files needed for development  Allows code signing of your app so it can be distributed
  • 6. Installing the ADT plugin (Link: http://developer.android.com/sdk/eclipse-adt.html#installing) To simplify ADT setup, it is recommend installing the Android SDK prior to installing ADT .Eclipse 3.5 (Galileo) and 3.6 (Helios) 1.Start Eclipse, then select Help>Install New Software.... 2.Click Add, in the top-right corner. 3.In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location: https://dl-ssl.google.com/android/eclipse/ Note: If you have troubles try using "http" instead of "https”Click OK. 4.In the Available Software dialog, select the checkbox next to Developer Tools and click Next. 5.In the next window, you'll see a list of the tools to be downloaded. Click Next. 6.Read and accept the license agreements, then click Finish. 7.When the installation completes, restart Eclipse.
  • 7. Configuring the ADT plugin 1.Select Window>Preferences...to open the Preferences panel (Mac OS X:Eclipse>Preferences). 2.Select Android from the left panel. 3.For the SDK Location in the main panel, click Browse...and locate your downloaded SDK directory (e.g. C:Program Filesandroid-sdk-windows) 4.Click Apply, then OK
  • 8. Android SDK and AVD manager  Add your virtual development devices using this  AVD is a target device simulator: no sensors
  • 10. Android SDK and AVD Manager  Used for updating Android SDK tools etc.
  • 11. Pointers Update the system’s PATH variable to recognize two folders inside your android-sdk-winwows. The first is: tools and the second is platform- tools. 1.Windows > Start > Control Panel > System > Advanced > Environment Variables > System Variables > PATH > Edit 2.Add references to the sub-folders mentioned above. In this example: c:android-sdk-windowstools;C:android-sdk-windowsplatform-tools; 3.OK Make sure Java and Eclipse Environments and path variables are setup correctly: Some interesting tutorials on Android projects can be found on: http://www.hometutorials.com/google-android.html
  • 15. Once you complete the New Project Wizard, ADT creates the following folders and files in your new project: •src/ Includes your stub Activity Java file. All other Java files for your application go here. •<Android Version>/ (e.g., Android 1.5/) Includes the android.jar file that your application will build against. •gen/ This contains the Java files generated by ADT, such as your R.java file and interfaces created from AIDL files. •assets/This is empty. You can use it to store raw asset files. •res/A folder for your application resources, such as drawable files, layout files, string values, etc. •AndroidManifest.xml The Android Manifest for your project. •default.propertiesThis file contains project settings, such as the build target. Android Project Components
  • 29. Accessing Sensors There are various sensors on the Android phones, e.g. GPS, camera, accelerometer  Cannot be tested on Simulator  Tutorial and sample source code to use GPS and accelerometer sensors available soon ● Using the Wi-Fi and Bluetooth Interfaces instructions on: http://www.tutorialforandroid.com/2009/10/turn-off-turn-on-wifi-in-android-using.html http://developer.android.com/guide/topics/wireless/bluetooth.html
  • 30. GPS Sensor Access ● To use GPS functionality in your Android application, you'll need to add the ACCESS_FINE_LOCATION permission to the AndroidManifest.xml file. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> ●In Android, location-based services are provided by the LocationManager class located in the android.location package. ● Using the LocationManager class, your application can obtain periodic updates of the device's geographical locations as well as fire an intent when it enters the proximity of a certain location.
  • 31. Accelerometer and Access to other Sensors ● An instance of the SensorManager is required in order to retrieve informations about the supported sensors. ● No permission is required to access the sensor service. It is then possible to retrieve the list of available sensors of a certain type. ● For an accelerometer sensor, the type to use is given by the Sensor.TYPE_ACCELEROMETER constant. ● If at least one Sensor exists, it is possible to register a SensorEventListener for a Sensor of the list. ● It is possible to specify the delivering rate for sensor events. Specified rate must be one of :
  • 32. SensorManager.SENSOR_DELAY_FASTEST : as fast as possible SensorManager.SENSOR_DELAY_GAME : rate suitable for game SensorManager.SENSOR_DELAY_NORMAL : normal rate SensorManager.SENSOR_DELAY_UI : rate suitable for UI Thread
  • 33. Android and Databases ● Access to remote database e.g. MySQL can occur using a PHP script hosted on the server performing the query and JSON formatting for data exchange for reference check out the example at: http://www.helloandroid.com/tutorials/connecting- mysql-database ● Local light weight database system. http://developer.android.com/reference/android/d atabase/sqlite/SQLiteDatabase.html