SlideShare a Scribd company logo
1 of 48
Download to read offline
Android Tutorial
Larry Walters
OOSE Fall 2011
References
 This tutorial is a brief overview of some major
concepts…Android is much richer and more
complex
 Developer’s Guide
 http://developer.android.com/guide/index.html
 API Reference
 http://developer.android.com/reference/packages.html
Tools
 Phone
 Eclipse ( http://www.eclipse.org/downloads/ )
 Android Plugin (ADT)
 Android SDK ( http://developer.android.com/sdk/index.html )
 Install everything except Additional SDK
Platforms, unless you want to
 Windows Users: may need to install Motorola
Driver directly (
http://www.motorola.com/Support/US-EN/Support-Homepage/Software_an
)
Android SDK
 Once installed open the SDK Manager
 Install the desired packages
 Create an Android Virtual Device (AVD)
SDK Manager
AVD
ADT Plugin (1)
 In Eclipse, go to Help -> Install New Software
 Click ‘Add’ in top right
 Enter:
 Name: ADT Plugin
 Location: https://dl-ssl.google.com/android/eclipse/
 Click OK, then select ‘Developer Tools’, click Next
 Click Next and then Finish
 Afterwards, restart Eclipse
 Specify SDK location (next 3 slides)
 Must do this every time start a new project in a new
location (at least in Windows)
ADT Plugin (2)
ADT Plugin (3)
ADT Plugin (4)
Creating a Project (1)
Creating a Project (2)
Need
the
items
circled
Then
click
Finish
Project Components
 src – your source code
 gen – auto-generated code (usually just R.java)
 Included libraries
 Resources
 Drawables (like .png images)
 Layouts
 Values (like strings)
 Manifest file
XML
 Used to define some of the resources
 Layouts (UI)
 Strings
 Manifest file
 Shouldn’t usually have to edit it directly,
Eclipse can do that for you
 Preferred way of creating UIs
 Separates the description of the layout from any
actual code that controls it
 Can easily take a UI from one platform to another
R Class
 Auto-generated: you shouldn’t edit it
 Contains IDs of the project resources
 Enforces good software engineering
 Use findViewById and Resources object to
get access to the resources
 Ex. Button b = (Button)findViewById(R.id.button1)
 Ex. getResources().getString(R.string.hello));
Layouts (1)
 Eclipse has a great UI creator
 Generates the XML for you
 Composed of View objects
 Can be specified for portrait and landscape
mode
 Use same file name, so can make completely
different UIs for the orientations without modifying
any code
Layouts (2)
Layouts (3)
 Click ‘Create’ to make layout modifications
 When in portrait mode can select ‘Portrait’ to make a
res sub folder for portrait layouts
 Likewise for Landscape layouts while in landscape mode
 Will create folders titled ‘layout-port’ and ‘layout-land’
 Note: these ‘port’ and ‘land’ folders are examples of
‘alternate layouts’, see here for more info
 http://developer.android.com/guide/topics/resources/providing-resources.html
 Avoid errors by making sure components have the
same id in both orientations, and that you’ve tested
each orientation thoroughly
Layouts (4)
Strings
 In res/values
 strings.xml
 Application wide available strings
 Promotes good software engineering
 UI components made in the UI editor should
have text defined in strings.xml
 Strings are just one kind of ‘Value’ there are
many others
Manifest File (1)
 Contains characteristics about your application
 When have more than one Activity in app, NEED to
specify it in manifest file
 Go to graphical view of the manifest file
 Add an Activity in the bottom right
 Browse for the name of the activity
 Need to specify Services and other components too
 Also important to define permissions and external
libraries, like Google Maps API
Manifest File (2) – Adding an Activity
Android Programming Components
 Activity
 http://developer.android.com/guide/topics/fundamentals/activities.html
 Service
 http://developer.android.com/guide/topics/fundamentals/services.html
 Content Providers
 Broadcast Receivers
 Android in a nutshell:
 http://developer.android.com/guide/topics/fundamentals.html
Activities (1)
 The basis of android applications
 A single Activity defines a single viewable
screen
 the actions, not the layout
 Can have multiple per application
 Each is a separate entity
 They have a structured life cycle
 Different events in their life happen either via the
user touching buttons or programmatically
Activities (2)
Services (1)
 Run in the background
 Can continue even if Activity that started it dies
 Should be used if something needs to be done while the user is not
interacting with application
 Otherwise, a thread is probably more applicable
 Should create a new thread in the service to do work in, since the
service runs in the main thread
 Can be bound to an application
 In which case will terminate when all applications bound to it unbind
 Allows multiple applications to communicate with it via a common
interface
 Needs to be declared in manifest file
 Like Activities, has a structured life cycle
Services (2)
Running in Eclipse (1)
 Similar to launching a regular Java app, use
the launch configurations
 Specify an Android Application and create a
new one
 Specify activity to be run
 Can select a manual option, so each time
program is run, you are asked whether you
want to use the actual phone or the emulator
 Otherwise, it should be smart and use whichever
one is available
Running in Eclipse (2)
Running in Eclipse (3)
Running in Eclipse (4)
USB Debugging
 Should be enabled on phone to use
developer features
 In the main apps screen select Settings ->
Applications -> Development -> USB
debugging (it needs to be checked)
Android Debug Bridge
 Used for a wide variety of developer tasks
 Read from the log file
 Show what android devices are available
 Install android applications (.apk files)
 In the ‘platform-tools’ directory of the main
android sdk directory
 Recommend putting this directory and the ‘tools’
directory on the system path
 adb.exe
Debugging
 Instead of using traditional System.out.println, use the Log class
 Imported with android.util.Log
 Multiple types of output (debug, warning, error, …)
 Log.d(<tag>,<string>)
 Can be read using logcat.
 Print out the whole log, which auto-updates
 adb logcat
 Erase log
 adb logcat –c
 Filter output via tags
 adb logcat <tag>:<msg type> *:S
 can have multiple <tag>:<msg type> filters
 <msg type> corresponds to debug, warning, error, etc.
 If use Log.d(), then <msg type> = D
 Reference
 http://developer.android.com/guide/developing/debugging/debugging-log.html
Screen Shots
 Some say you need to root the phone – that
is not true
 One option: Android Screen Capture
 http://www.mightypocket.com/2010/08/android-screens
 It’s slow, but fine for screenshots of applications
whose screens aren’t changing fast
 Read their installation help, following the extra
steps if need be (I had to copy adb.exe and some
dll files, as they explain)
Maps Example (1)
 Using Google Maps in your app
 Setup project to use ‘Google API’ version
 Edit Manifest file
 To indicate the app will use maps and the internet
 Get a maps API key
 Note: Google Maps API can display a map and draw overlays,
but is not the full Google Maps experience you enjoy on the web
 For example, there does not seem to be inherent support for
drawing routes between points (if you find it let me know)…
however, you can draw lines between points and almost any type
of overlay, but that’s different than street routes
 The directions API is a web service, which is different, among
several other Google web services
 Read the Google API terms of use
Maps Example (2)
Maps Example (3) – Manifest (1)
 Open Manifest file
 Add map library tag
 Add the ‘Uses Library’ com.google.android.maps
 Indicate the app will access the internet
 Add the ‘Permission’ android.permission.lNTERNET
 End goal is to add the following two lines to XML file,
under the <manifest> and <application tags>,
respectively
 Under the <manifest> tag
 <uses-permission android:name="android.permission.INTERNET"></uses-permission>
 Under the <application> tag
 <uses-library android:name="com.google.android.maps"></uses-library>
 Following is GUI way to add them
Maps Example (4) – Manifest (2)
1
2
Maps Example (5) – Manifest (3)
 Select ‘Add’ under ‘Uses Library’ (last slide)
 Then select ‘Uses Library at this prompt
 Set name as: com.google.android.maps (next
slide) and save
Maps Example (6) – Manifest (4)
Maps Example (7) – Manifest (5)
2
1
Maps Example (8) – Manifest (6)
 Select ‘Permissions’ and then ‘Add’ (last slide)
 Select ‘Uses Permissions’ at this prompt
 Set name to: android.permission.INTERNET
and save (next slide)
Maps Example (9) – Manifest (7)
Maps Example (10) – Maps API Key (1)
 All Android applications need to be signed
 The debug mode signs for you with special debug
certificate
 All MapView elements in map applications
need to have an API key associated with
them
 That key must be registered with the certificate
used to sign the app
 When releasing app, need to sign with a
release certificate and get a new API Key
Maps Example (11) – Maps API Key (2)
 For debug mode, get the MD5 fingerprint of the debug certificate
 Locate the ‘keystore’
 Windows Vista: C:Users<user>.androiddebug.keystore
 Windows XP: C:Documents and Settings<user>.androiddebug.keystore
 OS X and Linux: ~/.android/debug.keystore
 Use Keytool (comes with Java, in the bin directory with the other
Java tools, should put that dir on system PATH) to get fingerprint
 keytool -list –v -alias androiddebugkey -keystore
“<path_to_debug_keystore>” -storepass android -keypass android
 If don’t include –v option, then will probably get only 1 fingerprint, and if it’s
not MD5, then need –v (Java 7 needs –v)
 Extract the MD5 fingerprint, SHA will not work unfortunately
 Go to https://code.google. com/android/maps-api-signup.html ,
agree to terms and paste MD5 fingerprint, you will then be given
an API Key
Maps Example (12)
 Need to put MapView tag in XML
 com.google.android.maps.MapView
 MapView is the basic view that represents a Google Map
display
 Must include API Key in XML, inside a layout
 <com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey=“<api key>”/>
 Maps API Reference
 http://code.google.com/android/add-ons/google-apis/reference/index.html
Acknowledgements
 Android Developer’s Website
 Activity and Service life-cycle flow charts
 Tons of other Android info
 Google Maps API external library
 http://code.google.com/android/add-ons/google-apis/maps-overview.html
 MightyPocket
 http://www.mightypocket.com/2010/08/android-screenshots-screen-capture-screen-cast/
 Numerous Forums & other developer sites, including:
 http://www.javacodegeeks.com/2011/02/android-google-maps-tutorial.html
 http://efreedom.com/Question/1-6070968/Google-Maps-Api-Directions
 http://www.mail-archive.com/android-developers@googlegroups.com/msg28487.html
 http://android.bigresource.com/ threads
 http://groups.google.com/group/android-developers threads
 Many http://stackoverflow.com threads
 http://www.anddev.org/google_driving_directions_-_mapview_overlayed-t826.html
 Zainan Victor Zhou – for advice and his own tutorial

More Related Content

What's hot

Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentAhsanul Karim
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesAhsanul Karim
 
Multiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerMultiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerAhsanul Karim
 
Android deep dive
Android deep diveAndroid deep dive
Android deep diveAnuSahniNCI
 
Android Development project
Android Development projectAndroid Development project
Android Development projectMinhaj Kazi
 
Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Ahsanul Karim
 
Android In A Nutshell
Android In A NutshellAndroid In A Nutshell
Android In A NutshellTed Chien
 
Android software development – the first few hours
Android software development – the first few hoursAndroid software development – the first few hours
Android software development – the first few hourssjmarsh
 
What is Android?
What is Android?What is Android?
What is Android?ndalban
 
Android chapter02-setup2-emulator
Android chapter02-setup2-emulatorAndroid chapter02-setup2-emulator
Android chapter02-setup2-emulatorguru472
 
Android studio 2.0: default project structure
Android studio 2.0: default project structureAndroid studio 2.0: default project structure
Android studio 2.0: default project structureVyara Georgieva
 
Sensors in Android (old)
Sensors in Android (old)Sensors in Android (old)
Sensors in Android (old)Ahsanul Karim
 

What's hot (19)

Android session 1
Android session 1Android session 1
Android session 1
 
Android session 2
Android session 2Android session 2
Android session 2
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application Development
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
 
Android session 3
Android session 3Android session 3
Android session 3
 
Multiple Activity and Navigation Primer
Multiple Activity and Navigation PrimerMultiple Activity and Navigation Primer
Multiple Activity and Navigation Primer
 
GUI JAVA PROG ~hmftj
GUI  JAVA PROG ~hmftjGUI  JAVA PROG ~hmftj
GUI JAVA PROG ~hmftj
 
Android deep dive
Android deep diveAndroid deep dive
Android deep dive
 
Android Development project
Android Development projectAndroid Development project
Android Development project
 
Android xml-based layouts-chapter5
Android xml-based layouts-chapter5Android xml-based layouts-chapter5
Android xml-based layouts-chapter5
 
Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3
 
Android In A Nutshell
Android In A NutshellAndroid In A Nutshell
Android In A Nutshell
 
Android software development – the first few hours
Android software development – the first few hoursAndroid software development – the first few hours
Android software development – the first few hours
 
What is Android?
What is Android?What is Android?
What is Android?
 
Android overview
Android overviewAndroid overview
Android overview
 
AndroidManifest
AndroidManifestAndroidManifest
AndroidManifest
 
Android chapter02-setup2-emulator
Android chapter02-setup2-emulatorAndroid chapter02-setup2-emulator
Android chapter02-setup2-emulator
 
Android studio 2.0: default project structure
Android studio 2.0: default project structureAndroid studio 2.0: default project structure
Android studio 2.0: default project structure
 
Sensors in Android (old)
Sensors in Android (old)Sensors in Android (old)
Sensors in Android (old)
 

Viewers also liked

발표자료 - 스마트 금융의 진화로 다변화된 플랫폼 대응 방안 - 알서포트
발표자료 - 스마트 금융의 진화로 다변화된 플랫폼 대응 방안 - 알서포트발표자료 - 스마트 금융의 진화로 다변화된 플랫폼 대응 방안 - 알서포트
발표자료 - 스마트 금융의 진화로 다변화된 플랫폼 대응 방안 - 알서포트RSUPPORT
 
Onore de balzac
Onore de balzacOnore de balzac
Onore de balzacovakula
 
Isp introduction to blackboard
Isp introduction to blackboardIsp introduction to blackboard
Isp introduction to blackboardannemiekwegman
 
20120707 designjam777
20120707 designjam77720120707 designjam777
20120707 designjam777soc00
 
온라인 영화예매 서비스
온라인 영화예매 서비스온라인 영화예매 서비스
온라인 영화예매 서비스heeyoon6550
 
Ibm Microfinance Sept 09
Ibm Microfinance Sept 09Ibm Microfinance Sept 09
Ibm Microfinance Sept 09ivanadarma
 
Form pit-36 l-11-2015-2016
Form pit-36 l-11-2015-2016Form pit-36 l-11-2015-2016
Form pit-36 l-11-2015-2016UrzadSkarbowy24
 
Service design panel
Service design panelService design panel
Service design panelBom Kim
 
エンジニア 李昇禹(イスンウ) 履歴書 (20160410)
エンジニア 李昇禹(イスンウ) 履歴書 (20160410)エンジニア 李昇禹(イスンウ) 履歴書 (20160410)
エンジニア 李昇禹(イスンウ) 履歴書 (20160410)SeungWoo Lee
 
digital electronics
digital electronicsdigital electronics
digital electronicsjani
 
Effectivepresentationskills 140107055722-phpapp02
Effectivepresentationskills 140107055722-phpapp02Effectivepresentationskills 140107055722-phpapp02
Effectivepresentationskills 140107055722-phpapp02Helen Hendrickson
 

Viewers also liked (16)

발표자료 - 스마트 금융의 진화로 다변화된 플랫폼 대응 방안 - 알서포트
발표자료 - 스마트 금융의 진화로 다변화된 플랫폼 대응 방안 - 알서포트발표자료 - 스마트 금융의 진화로 다변화된 플랫폼 대응 방안 - 알서포트
발표자료 - 스마트 금융의 진화로 다변화된 플랫폼 대응 방안 - 알서포트
 
Cloud and Big data mgt
Cloud and Big data mgtCloud and Big data mgt
Cloud and Big data mgt
 
Onore de balzac
Onore de balzacOnore de balzac
Onore de balzac
 
Isp introduction to blackboard
Isp introduction to blackboardIsp introduction to blackboard
Isp introduction to blackboard
 
THE HISTORY OF THE CHILDREN OF ISRAEL
THE HISTORY OF THE CHILDREN OF ISRAELTHE HISTORY OF THE CHILDREN OF ISRAEL
THE HISTORY OF THE CHILDREN OF ISRAEL
 
Our food diary mireia natalia lucia 5a
Our food diary mireia natalia lucia 5aOur food diary mireia natalia lucia 5a
Our food diary mireia natalia lucia 5a
 
20120707 designjam777
20120707 designjam77720120707 designjam777
20120707 designjam777
 
온라인 영화예매 서비스
온라인 영화예매 서비스온라인 영화예매 서비스
온라인 영화예매 서비스
 
Ibm Microfinance Sept 09
Ibm Microfinance Sept 09Ibm Microfinance Sept 09
Ibm Microfinance Sept 09
 
Vat 23
Vat 23Vat 23
Vat 23
 
Agonia
AgoniaAgonia
Agonia
 
Form pit-36 l-11-2015-2016
Form pit-36 l-11-2015-2016Form pit-36 l-11-2015-2016
Form pit-36 l-11-2015-2016
 
Service design panel
Service design panelService design panel
Service design panel
 
エンジニア 李昇禹(イスンウ) 履歴書 (20160410)
エンジニア 李昇禹(イスンウ) 履歴書 (20160410)エンジニア 李昇禹(イスンウ) 履歴書 (20160410)
エンジニア 李昇禹(イスンウ) 履歴書 (20160410)
 
digital electronics
digital electronicsdigital electronics
digital electronics
 
Effectivepresentationskills 140107055722-phpapp02
Effectivepresentationskills 140107055722-phpapp02Effectivepresentationskills 140107055722-phpapp02
Effectivepresentationskills 140107055722-phpapp02
 

Similar to Android tutorial

Industrial Training in Android Application
Industrial Training in Android ApplicationIndustrial Training in Android Application
Industrial Training in Android ApplicationArcadian Learning
 
Rola azab (2)
Rola azab (2)Rola azab (2)
Rola azab (2)Rola Azab
 
Android installation guide
Android installation guideAndroid installation guide
Android installation guidemagicshui
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorialmaster760
 
Android chapter02-setup1-sdk
Android chapter02-setup1-sdkAndroid chapter02-setup1-sdk
Android chapter02-setup1-sdkTran Le Hoan
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studioParinita03
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answerskavinilavuG
 
Android development-tutorial
Android development-tutorialAndroid development-tutorial
Android development-tutorialilias ahmed
 
Android app development ppt
Android app development pptAndroid app development ppt
Android app development pptsaitej15
 
Synapseindia android apps intro to android development
Synapseindia android apps  intro to android developmentSynapseindia android apps  intro to android development
Synapseindia android apps intro to android developmentSynapseindiappsdevelopment
 

Similar to Android tutorial (20)

Industrial Training in Android Application
Industrial Training in Android ApplicationIndustrial Training in Android Application
Industrial Training in Android Application
 
Rola azab (2)
Rola azab (2)Rola azab (2)
Rola azab (2)
 
Android - Android Application Configuration
Android - Android Application ConfigurationAndroid - Android Application Configuration
Android - Android Application Configuration
 
Android installation guide
Android installation guideAndroid installation guide
Android installation guide
 
Android Basic- CMC
Android Basic- CMCAndroid Basic- CMC
Android Basic- CMC
 
IntroToAndroid
IntroToAndroidIntroToAndroid
IntroToAndroid
 
Notes Unit2.pptx
Notes Unit2.pptxNotes Unit2.pptx
Notes Unit2.pptx
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Google Android
Google AndroidGoogle Android
Google Android
 
Android chapter02-setup1-sdk
Android chapter02-setup1-sdkAndroid chapter02-setup1-sdk
Android chapter02-setup1-sdk
 
PPT Companion to Android
PPT Companion to AndroidPPT Companion to Android
PPT Companion to Android
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answers
 
Android development-tutorial
Android development-tutorialAndroid development-tutorial
Android development-tutorial
 
Android
Android Android
Android
 
Android Basic
Android BasicAndroid Basic
Android Basic
 
Android dev o_auth
Android dev o_authAndroid dev o_auth
Android dev o_auth
 
Intro to Android Programming
Intro to Android ProgrammingIntro to Android Programming
Intro to Android Programming
 
Android app development ppt
Android app development pptAndroid app development ppt
Android app development ppt
 
Synapseindia android apps intro to android development
Synapseindia android apps  intro to android developmentSynapseindia android apps  intro to android development
Synapseindia android apps intro to android development
 

Recently uploaded

Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampVICTOR MAESTRE RAMIREZ
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024Mind IT Systems
 
Introduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntroduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntelliSource Technologies
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIIvo Andreev
 
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfTobias Schneck
 
About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9Jürgen Gutsch
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxAutus Cyber Tech
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLAlluxio, Inc.
 
Why Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfWhy Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfBrain Inventory
 
Growing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesGrowing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesSoftwareMill
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Jaydeep Chhasatia
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorShane Coughlan
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?AmeliaSmith90
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyRaymond Okyere-Forson
 
eAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionseAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionsNirav Modi
 
Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Neo4j
 
Watermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesWatermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesShyamsundar Das
 

Recently uploaded (20)

Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - Datacamp
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024
 
Introduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntroduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptx
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AI
 
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
 
About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in Trivandrum
 
Program with GUTs
Program with GUTsProgram with GUTs
Program with GUTs
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptx
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
 
Why Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfWhy Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdf
 
Growing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesGrowing Oxen: channel operators and retries
Growing Oxen: channel operators and retries
 
Sustainable Web Design - Claire Thornewill
Sustainable Web Design - Claire ThornewillSustainable Web Design - Claire Thornewill
Sustainable Web Design - Claire Thornewill
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS Calculator
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human Beauty
 
eAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionseAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspections
 
Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!
 
Watermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesWatermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security Challenges
 

Android tutorial

  • 2. References  This tutorial is a brief overview of some major concepts…Android is much richer and more complex  Developer’s Guide  http://developer.android.com/guide/index.html  API Reference  http://developer.android.com/reference/packages.html
  • 3. Tools  Phone  Eclipse ( http://www.eclipse.org/downloads/ )  Android Plugin (ADT)  Android SDK ( http://developer.android.com/sdk/index.html )  Install everything except Additional SDK Platforms, unless you want to  Windows Users: may need to install Motorola Driver directly ( http://www.motorola.com/Support/US-EN/Support-Homepage/Software_an )
  • 4. Android SDK  Once installed open the SDK Manager  Install the desired packages  Create an Android Virtual Device (AVD)
  • 6. AVD
  • 7. ADT Plugin (1)  In Eclipse, go to Help -> Install New Software  Click ‘Add’ in top right  Enter:  Name: ADT Plugin  Location: https://dl-ssl.google.com/android/eclipse/  Click OK, then select ‘Developer Tools’, click Next  Click Next and then Finish  Afterwards, restart Eclipse  Specify SDK location (next 3 slides)  Must do this every time start a new project in a new location (at least in Windows)
  • 12. Creating a Project (2) Need the items circled Then click Finish
  • 13. Project Components  src – your source code  gen – auto-generated code (usually just R.java)  Included libraries  Resources  Drawables (like .png images)  Layouts  Values (like strings)  Manifest file
  • 14. XML  Used to define some of the resources  Layouts (UI)  Strings  Manifest file  Shouldn’t usually have to edit it directly, Eclipse can do that for you  Preferred way of creating UIs  Separates the description of the layout from any actual code that controls it  Can easily take a UI from one platform to another
  • 15. R Class  Auto-generated: you shouldn’t edit it  Contains IDs of the project resources  Enforces good software engineering  Use findViewById and Resources object to get access to the resources  Ex. Button b = (Button)findViewById(R.id.button1)  Ex. getResources().getString(R.string.hello));
  • 16. Layouts (1)  Eclipse has a great UI creator  Generates the XML for you  Composed of View objects  Can be specified for portrait and landscape mode  Use same file name, so can make completely different UIs for the orientations without modifying any code
  • 18. Layouts (3)  Click ‘Create’ to make layout modifications  When in portrait mode can select ‘Portrait’ to make a res sub folder for portrait layouts  Likewise for Landscape layouts while in landscape mode  Will create folders titled ‘layout-port’ and ‘layout-land’  Note: these ‘port’ and ‘land’ folders are examples of ‘alternate layouts’, see here for more info  http://developer.android.com/guide/topics/resources/providing-resources.html  Avoid errors by making sure components have the same id in both orientations, and that you’ve tested each orientation thoroughly
  • 20. Strings  In res/values  strings.xml  Application wide available strings  Promotes good software engineering  UI components made in the UI editor should have text defined in strings.xml  Strings are just one kind of ‘Value’ there are many others
  • 21. Manifest File (1)  Contains characteristics about your application  When have more than one Activity in app, NEED to specify it in manifest file  Go to graphical view of the manifest file  Add an Activity in the bottom right  Browse for the name of the activity  Need to specify Services and other components too  Also important to define permissions and external libraries, like Google Maps API
  • 22. Manifest File (2) – Adding an Activity
  • 23. Android Programming Components  Activity  http://developer.android.com/guide/topics/fundamentals/activities.html  Service  http://developer.android.com/guide/topics/fundamentals/services.html  Content Providers  Broadcast Receivers  Android in a nutshell:  http://developer.android.com/guide/topics/fundamentals.html
  • 24. Activities (1)  The basis of android applications  A single Activity defines a single viewable screen  the actions, not the layout  Can have multiple per application  Each is a separate entity  They have a structured life cycle  Different events in their life happen either via the user touching buttons or programmatically
  • 26. Services (1)  Run in the background  Can continue even if Activity that started it dies  Should be used if something needs to be done while the user is not interacting with application  Otherwise, a thread is probably more applicable  Should create a new thread in the service to do work in, since the service runs in the main thread  Can be bound to an application  In which case will terminate when all applications bound to it unbind  Allows multiple applications to communicate with it via a common interface  Needs to be declared in manifest file  Like Activities, has a structured life cycle
  • 28. Running in Eclipse (1)  Similar to launching a regular Java app, use the launch configurations  Specify an Android Application and create a new one  Specify activity to be run  Can select a manual option, so each time program is run, you are asked whether you want to use the actual phone or the emulator  Otherwise, it should be smart and use whichever one is available
  • 32. USB Debugging  Should be enabled on phone to use developer features  In the main apps screen select Settings -> Applications -> Development -> USB debugging (it needs to be checked)
  • 33. Android Debug Bridge  Used for a wide variety of developer tasks  Read from the log file  Show what android devices are available  Install android applications (.apk files)  In the ‘platform-tools’ directory of the main android sdk directory  Recommend putting this directory and the ‘tools’ directory on the system path  adb.exe
  • 34. Debugging  Instead of using traditional System.out.println, use the Log class  Imported with android.util.Log  Multiple types of output (debug, warning, error, …)  Log.d(<tag>,<string>)  Can be read using logcat.  Print out the whole log, which auto-updates  adb logcat  Erase log  adb logcat –c  Filter output via tags  adb logcat <tag>:<msg type> *:S  can have multiple <tag>:<msg type> filters  <msg type> corresponds to debug, warning, error, etc.  If use Log.d(), then <msg type> = D  Reference  http://developer.android.com/guide/developing/debugging/debugging-log.html
  • 35. Screen Shots  Some say you need to root the phone – that is not true  One option: Android Screen Capture  http://www.mightypocket.com/2010/08/android-screens  It’s slow, but fine for screenshots of applications whose screens aren’t changing fast  Read their installation help, following the extra steps if need be (I had to copy adb.exe and some dll files, as they explain)
  • 36. Maps Example (1)  Using Google Maps in your app  Setup project to use ‘Google API’ version  Edit Manifest file  To indicate the app will use maps and the internet  Get a maps API key  Note: Google Maps API can display a map and draw overlays, but is not the full Google Maps experience you enjoy on the web  For example, there does not seem to be inherent support for drawing routes between points (if you find it let me know)… however, you can draw lines between points and almost any type of overlay, but that’s different than street routes  The directions API is a web service, which is different, among several other Google web services  Read the Google API terms of use
  • 38. Maps Example (3) – Manifest (1)  Open Manifest file  Add map library tag  Add the ‘Uses Library’ com.google.android.maps  Indicate the app will access the internet  Add the ‘Permission’ android.permission.lNTERNET  End goal is to add the following two lines to XML file, under the <manifest> and <application tags>, respectively  Under the <manifest> tag  <uses-permission android:name="android.permission.INTERNET"></uses-permission>  Under the <application> tag  <uses-library android:name="com.google.android.maps"></uses-library>  Following is GUI way to add them
  • 39. Maps Example (4) – Manifest (2) 1 2
  • 40. Maps Example (5) – Manifest (3)  Select ‘Add’ under ‘Uses Library’ (last slide)  Then select ‘Uses Library at this prompt  Set name as: com.google.android.maps (next slide) and save
  • 41. Maps Example (6) – Manifest (4)
  • 42. Maps Example (7) – Manifest (5) 2 1
  • 43. Maps Example (8) – Manifest (6)  Select ‘Permissions’ and then ‘Add’ (last slide)  Select ‘Uses Permissions’ at this prompt  Set name to: android.permission.INTERNET and save (next slide)
  • 44. Maps Example (9) – Manifest (7)
  • 45. Maps Example (10) – Maps API Key (1)  All Android applications need to be signed  The debug mode signs for you with special debug certificate  All MapView elements in map applications need to have an API key associated with them  That key must be registered with the certificate used to sign the app  When releasing app, need to sign with a release certificate and get a new API Key
  • 46. Maps Example (11) – Maps API Key (2)  For debug mode, get the MD5 fingerprint of the debug certificate  Locate the ‘keystore’  Windows Vista: C:Users<user>.androiddebug.keystore  Windows XP: C:Documents and Settings<user>.androiddebug.keystore  OS X and Linux: ~/.android/debug.keystore  Use Keytool (comes with Java, in the bin directory with the other Java tools, should put that dir on system PATH) to get fingerprint  keytool -list –v -alias androiddebugkey -keystore “<path_to_debug_keystore>” -storepass android -keypass android  If don’t include –v option, then will probably get only 1 fingerprint, and if it’s not MD5, then need –v (Java 7 needs –v)  Extract the MD5 fingerprint, SHA will not work unfortunately  Go to https://code.google. com/android/maps-api-signup.html , agree to terms and paste MD5 fingerprint, you will then be given an API Key
  • 47. Maps Example (12)  Need to put MapView tag in XML  com.google.android.maps.MapView  MapView is the basic view that represents a Google Map display  Must include API Key in XML, inside a layout  <com.google.android.maps.MapView android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" android:apiKey=“<api key>”/>  Maps API Reference  http://code.google.com/android/add-ons/google-apis/reference/index.html
  • 48. Acknowledgements  Android Developer’s Website  Activity and Service life-cycle flow charts  Tons of other Android info  Google Maps API external library  http://code.google.com/android/add-ons/google-apis/maps-overview.html  MightyPocket  http://www.mightypocket.com/2010/08/android-screenshots-screen-capture-screen-cast/  Numerous Forums & other developer sites, including:  http://www.javacodegeeks.com/2011/02/android-google-maps-tutorial.html  http://efreedom.com/Question/1-6070968/Google-Maps-Api-Directions  http://www.mail-archive.com/android-developers@googlegroups.com/msg28487.html  http://android.bigresource.com/ threads  http://groups.google.com/group/android-developers threads  Many http://stackoverflow.com threads  http://www.anddev.org/google_driving_directions_-_mapview_overlayed-t826.html  Zainan Victor Zhou – for advice and his own tutorial